Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

adodc refresh method failed

hello all,

i tried to assign the recordsource property of an adodc control on my form to a variable, however it says my sql syntax is not correct and refer to its manual.
and then the refresh method failed.

here is my code:

Private Sub Command4_Click()
Dim strQuery As String

strQuery = "Select * from (bedrijf) where bedrijfnaam = 'RBTT'"

AdoBedrijf.RecordSource = strQuery
AdoBedrijf.Refresh

DataList1.ReFill
DataList1.Refresh

End Sub

how ever i tried every possible sql query string. No luck. My database is an mysql database.

Where i'am going wrong?
Can someone please help me?

thanks,
Randjana
[760 byte] By [randjana] at [2007-11-11 8:37:06]
# 1 Re: adodc refresh method failed
Try removing the parenthesis from the table name.
pclement at 2007-11-11 17:25:13 >
# 2 Re: adodc refresh method failed
removed it and get the same
randjana at 2007-11-11 17:26:13 >
# 3 Re: adodc refresh method failed
What are you using for a connection string?
edburdo at 2007-11-11 17:27:23 >
# 4 Re: adodc refresh method failed
Mysql odbc 3.51
randjana at 2007-11-11 17:28:19 >
# 5 Re: adodc refresh method failed
Could you post the exact error message?
pclement at 2007-11-11 17:29:18 >
# 6 Re: adodc refresh method failed
First when the button is clicked, this is the error message:

[MySQL][ODBC 3.51 Driver][mysqld-5.0.19-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Select * from bedrijf where bedrijfnaam = 'RBTT'' at line 1

and after this:

Run-time error '-2147217900 (80040e14)':
Method 'refresh' of object 'IAdodc' failed

And if I debug then AdoBedrijf.Refresh is yellow.
randjana at 2007-11-11 17:30:17 >
# 7 Re: adodc refresh method failed
helo all,

My problem is solved!!! thank you for all yor efforts.

Changed commandType value from 2-adcmd table to 8 - adCmdUnknown and it does exactly what i wanted. Once again thanks......

But there is now something else. with a button click i want to display company names in the datalist starting with a,b,c,d,e, eg.

something like

strQuery = "Select * from bedrijf where bedrijfnaam like 'a%', 'b%', 'c%', 'd%'"
Is it possible to do this with a query in vb?

Thanks,
randjana at 2007-11-11 17:31:20 >
# 8 Re: adodc refresh method failed
Believe it or not that was my next suggestion (although adCmdText is appropriate). ;-)

I'm not sure what the MySQL SQL syntax might be but you could try the following:

strQuery = "Select * from bedrijf where bedrijfnaam like '[abcd]%'"
pclement at 2007-11-11 17:32:20 >
# 9 Re: adodc refresh method failed
Thanks paul
I tried what you suggest and it just diplay no data in the datalist wheb the button is clicked.
randjana at 2007-11-11 17:33:28 >
# 10 Re: adodc refresh method failed
You may want to try their support forums. I don't have MySQL installed so I'm afraid I can't provide the correct syntax.

http://forums.mysql.com/
pclement at 2007-11-11 17:34:29 >
# 11 Re: adodc refresh method failed
Ok Paul i'll do that,

Thanks for your help!
randjana at 2007-11-11 17:35:27 >