PDA

Click to See Complete Forum and Search --> : Syntax error in "From" clause while using ADODC


pondymohan
Jul 29th, 2004, 02:25 PM
Hi,

I want to use "Adodc control in my Form.

I have to necessarily use a variable name as "Table Name"


I've used "From clause" within : With Adodc1...End With block

ie. .RecordSource = " Select * From" & tableid

I encouter : "Syntax error in From clause" when I run the application.

Will you debug the syntax error please ?


Actaul code
============


Private Sub Form_Load()

Dim tableid As Integer
tableid = 10


dbfile = App.Path & "\myfile.mdb"
Set CN = New ADODB.Connection
CN.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source='" & dbfile & "';" & _
"Persist Security Info=False"
CN.Open

-----------------------------------------------------
With Adodc1

.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source='" & dbfile & "';" & _
"Persist Security Info=False"

.RecordSource = " Select * From" & tableid <----

End With
-----------------------------------------------------

Set Text1.DataSource = Adodc1
Set Text2.DataSource = Adodc1
Text1.DataField = "Student_id"
Text2.DataField = "Student_name"

End sub

techgnome
Jul 29th, 2004, 03:42 PM
check your other thread, the answer is there.

TG