Private Sub cmdEnter_Click()
Dim cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\TJXDoc\DataBase\TjxDB.mdb;Persist Security Info=False"
Rs.CursorLocation = adUseClient
Dim strSelect As String
Dim strTxt As String
strTxt = Trim(txtInputData.Text)
Dim i As Long
'i = CLng(strTxt)
strSelect = "SELECT CUMULATIVE FROM TAXABLE WHERE Taxable_Income_min<= '" + strTxt + "' and Taxable_Income_max >= '" + strTxt + "' "
Rs.Open strSelect, cn, adOpenDynamic, adLockBatchOptimistic
'Rs.Open (strSelect,cn,adOpenDynamic ,adLockBatchOptimistic,1)
If Rs.EOF Then
txtInputData.Text = "False"
'txtInputData.Text = Rs.Fields.Item.Value
cn.Close
Else
txtInputData.Text = Rs.Fields(0).Value
' txtInputData.Text = "False"
cn.Close
End If
End Sub
事件一触发,就说我的标准表达式的数据类型不匹配,请各位大侠帮忙解决,还有,我想知道用access是否可以想SQL server那样可以执行我的SELECT语句之类的呢?最好能够提供如何访问VB自带的数据库,因为本人是做学校作业,以前没有学过编程的,谢谢
Dim cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\TJXDoc\DataBase\TjxDB.mdb;Persist Security Info=False"
Rs.CursorLocation = adUseClient
Dim strSelect As String
Dim strTxt As String
strTxt = Trim(txtInputData.Text)
Dim i As Long
'i = CLng(strTxt)
strSelect = "SELECT CUMULATIVE FROM TAXABLE WHERE Taxable_Income_min<= '" + strTxt + "' and Taxable_Income_max >= '" + strTxt + "' "
Rs.Open strSelect, cn, adOpenDynamic, adLockBatchOptimistic
'Rs.Open (strSelect,cn,adOpenDynamic ,adLockBatchOptimistic,1)
If Rs.EOF Then
txtInputData.Text = "False"
'txtInputData.Text = Rs.Fields.Item.Value
cn.Close
Else
txtInputData.Text = Rs.Fields(0).Value
' txtInputData.Text = "False"
cn.Close
End If
End Sub
事件一触发,就说我的标准表达式的数据类型不匹配,请各位大侠帮忙解决,还有,我想知道用access是否可以想SQL server那样可以执行我的SELECT语句之类的呢?最好能够提供如何访问VB自带的数据库,因为本人是做学校作业,以前没有学过编程的,谢谢
可以
Public rstUser As Recordset
Set conUser = New Connection
Set comUser = New Command
Set rstUser = New Recordset
With rstUser
.CursorType = adOpenDynamic
.CursorLocation = adUseServer
.LockType = adLockOptimistic
End With
With conUser.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Sound;Data Source=127.0.0.1"
.Open
End With
rstUser.Open "select * from clientUser where userName = '" & finalUserName & "'", conUser