匹配数据库中的文件

时间:2013-12-08 15:24:22

标签: sql sql-server vb6

我有一个问题,我无法得到一个'msg box'告诉我我浏览过的文件与数据库中的文件匹配。我使用SQL Server数据库,我已经插入了与我正在浏览的文件匹配的数据。这是我的代码:

Private Sub CmdUp_Click()

db

End Sub

Public Sub db()

Dim DBCon As ADODB.Connection
Dim Cmd As ADODB.Command
Dim Rs As ADODB.Recordset
Dim strName As String
 Dim file As String

file = Text1.Text

Set DBCon = New ADODB.Connection
    DBCon.CursorLocation = adUseClient

DBCon.Open "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Port=3306;Database=mforce; User=root;Password=;Option=3;"

Set Cmd = New ADODB.Command
Cmd.ActiveConnection = DBCon
Cmd.CommandType = adCmdText
Cmd.CommandText = "SELECT Sample FROM static WHERE ID = 1"

Set Rs = Cmd.Execute

Do While Not Rs.EOF

    Rs.MoveNext

Loop

 If Form1.Text1.Text = strName Then
   MsgBox " sample match"

End If
DBCon.Close

'Delete all references
Set Rs = Nothing
Set Cmd = Nothing
Set DBCon = Nothing

End Sub

0 个答案:

没有答案