关于select * from 的表达式
Private Sub Command1_Click()
Dim sc As Integer, time As String
Dim username As String, userpass As String
username = Text1.Text
userpass = Text2.Text
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox ("请输入用户名和密码")
Else
sc = 1
If sc = 1 Then
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
Str2 = "Data Source=huwu.mdb;"
Str3 = "Persist Security Info=False"
conn.Open Str1 & Str2 & Str3
strSQL = "select * from 用户 where 用户名='" & username & " ' and 密码='" & userpass & "'"
rs.Open strSQL, conn, 3, 3
If rs.EOF Then
MsgBox "用户密码错误"
Text1 = ""
Text2 = ""
Text1.SetFocus
Else
MsgBox "登录成功"
Unload Me
End If
rs.Close
conn.Close
Adodc1.Refresh
End If
Text1.Text = ""
Text2.Text = ""
End If
End Sub
这是一个完整的登录
中间的红色部分是SELECT * FROM 这个问题
Private Sub Command5_Click()
Dim sc As Integer
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Dim zhuhao As String, kuanshi As String, yanshe As String, chima As String
zhuhao = Cbo5.Text
kuanshi = Cbo6.Text
yanshe = Cbo7.Text
shima = Cbo8.Text
Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
Str2 = "Data Source=huwu.mdb;"
Str3 = "Persist Security Info=False"
conn.Open Str1 & Str2 & Str3
strSQL = "select 组号, from biaodou" '这个地方我想用AND 但是表达式 是不是还可以用别的呀
我想查询组号,款式,颜色,尺寸 这个 但是我不知道 如何去写这个表
式了
rs.Open strSQL, conn, 3, 3
我想查询 表里面的这四个列名 和输入的比较 SET SQL=SELET "" 不知道如何写
[解决办法]
Ctrl+T里面找Microsoft DataGrid ...
然后工具箱里就多一个图标,在窗体上画一个
用来显示记录集
strSQL = "select 组号,款式,颜色,尺寸 from biaodou"
'在VB菜单:工程->引用 里面找 Microsoft ActiveX Data Object 2.8 Library,并勾选上
Dim cn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim SqlStr As String cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Mode=ReadWrite;Persist Security Info=False;Jet OLEDB:Database Password=111" SqlStr = select 组号,款式,颜色,尺寸 from biaodou" rst.CursorLocation = adUseClient rst.Open SqlStr, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集Set DataGrid1.DataSource = rst '给DataGrid修改数据源
[解决办法]
Rs.RecordCount ' 返回记录集总(行)数
对于某一记录集(相当于表中某一行)
Rs.Fields.Count '返回的记录集总列数
Rs.Fields(i).value'第i列的值
Rs.MoveNext'下一条记录
[解决办法]
Rs.Fields(i).value'第i+1个字段的值