现在具体讲我的代码:
Dim user As String, pwd As String
Dim conn As ADODB.Connection
Dim r As ADODB.Recordset 在form窗体中的通用中定义
#################################################
Private Sub Command1_Click()
Set r = New ADODB.Recordset
Dim strsql As String
user = txtuser
pwd = txtpwd
strsql = "select * from yonghu where name='" & user & "'and pwd='" & pwd & "'"
r.Open strsql, conn
If r.EOF Then
MsgBox "登陆失败"
Else
MsgBox "登陆成功"
Unload Me
Form2.Show
r.Close
End If
End Sub
-------------------------------------------
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Connection
conn.ConnectionString = "driver={sql server};server=dengjiaxiong;uid=sa;pwd=;dataname=school"
conn.Open
If conn.State = adStateOpen Then
MsgBox "connection successfull!"
End If
End Sub
--------------------------------------------
Private Sub Label1_Click()
txtuser = ""
txtpwd = ""
End Sub
#########################################在form中定义
以下为第二个form窗体
Dim rs_shuju As New ADODB.Recordset
Dim rs_jiage As New ADODB.Recordset 在通用中定义
————————————————--------
Private Sub Command1_Click()
Dim strsql As String
user = txtuser
pwd = txtpwd
strsql = "select * from yonghu where name='" & user & "'and pwd='" & pwd & "'"
r.Open strsql, conn
Set DataGrid1.DataSource = r
End Sub
Private Sub Command2_Click()
txtuser = ""
txtpwd = ""
txtuser.SetFocus
End Sub
Private Sub Command3_Click()
If Text4.Text = "" Then
MsgBox "id不能空!"
Text4.SetFocus
End If
rs_shuju.AddNew
rs_shuju.Fields(0) = Val(Text4.Text)
rs_shuju.Fields(1) = Text5.Text
rs_shuju.Fields(2) = Val(Text6.Text)
rs_shuju.Fields(3) = Val(Text7.Text)
rs_shuju.Fields(4) = Val(Text8.Text)
rs_shuju.Fields(5) = Val(Text9.Text)
rs_shuju.Update
End Sub
Private Sub Command6_Click()
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text4.SetFocus
End Sub
Private Sub DataGrid1_Click()
End Sub
Private Sub Form_Load()
Dim sql_shuju As String
Dim sql_jiage As String
sql_shuju = "select * from p123"
rs_shuju.Open sql_shuju, -----------------------------------语句报错行 提示 实时 3001 参数类型不正确 或不在可以接受的范围之内或于其他参数冲突
connsql_jiage = "select * from 水电气价格表"
rs_jiage.Open sql_jiage, conn
End Sub
在第二个窗体中定义
----------------------------