Need Help on txt Urgently
can anyone tell me what had went wrong ? my database not working thank you =)
VB Code:
Dim SQL2 As String
Dim strLine As String, strFullPath As String
Dim ff As Integer, iCount As Integer
Dim conn2 As ADODB.Connection
Set conn2 = New ADODB.Connection
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
conn2.Open "DRIVER={MySQL ODBC 3.51 Driver};" & _
"Server=localhost;" & _
"Port=3306;" & _
"Option=131072;" & _
"Stmt=;" & _
"Database=rach2;" & _
"Uid=eugene;" & _
"Pwd=rant;"
ff = FreeFile
x = 0
Open myfile For Input As #ff
txtHaha.Text = vbNullString
Do While Not EOF(ff)
Line Input #ff, strLine
strLine = "1310" + strLine
'inside my txt files will have numbers 131094567485 etc
SQL2 = "SELECT callerId, callDate, callTime FROM call_dc WHERE DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= callDate AND callerId = " + strLine
rs2.CursorLocation = adUseClient
rs2.Open SQL2, conn2, adOpenForwardOnly, adLockReadOnly
Do While Not rs2.EOF
'if database number = txt number then it will list out in the text box where txtHaha is
If rs2.Fields("callerId") = strLine Then
txtHaha.Text = strLine
x = x + 1
End If
rs2.MoveNext
Loop
Loop
Close #ff
MsgBox x
MsgBox ("Section Complete Please Open Another File")
Re: Need Help on txt Urgently
whats the error
Oh and a side note.. do not use '+' to concat strings.. use &
strLine = "1310" & strLine
Re: Need Help on txt Urgently
ic i have no errors but it just stuck on the first one and then it wont move next to the database. anyway what im trying to do is to do a compare with the database from my text file and if there is = 131094523433 then it will show it in the text field can you help me ?
Re: Need Help on txt Urgently
Put a break at the beginning and step through it to see if you can determine what is happening.
Re: Need Help on txt Urgently
i tried nothings happening it wont go to the database i duno y
Re: Need Help on txt Urgently
no matter how i try or put a msgbox to state im here but it dosent go to the do while not rs2.eof it wont get in hmm did i misplace something ? or i left out some codes ?
Re: Need Help on txt Urgently
1) make sure you replace + with & in this line
SQL2 = "SELECT callerId, callDate, callTime FROM call_dc WHERE DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= callDate AND callerId = " + strLine
SQL2 = "SELECT callerId, callDate, callTime FROM call_dc WHERE DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= callDate AND callerId = " & strLine
next - right after that line
put
Debug.print strLine
and see what it spits out in the debug window.
check to make sure those values are in your DB
Re: Need Help on txt Urgently
i trieid but nothing happened
Re: Need Help on txt Urgently
now it has errors it says that the item cannot be found in the collection corrospond to the requested name or ordinal
Re: Need Help on txt Urgently
It can't find a Field. Does this help (rearnging the syntax):
VB Code:
SQL2 = "SELECT callerId, callDate, callTime FROM call_dc WHERE [b]callDate >= DATE_SUB(CURDATE(),INTERVAL 3 DAY)[/b] AND callerId = " [b]&[/b] strLine
Re: Need Help on txt Urgently
erm the syntax is correct