3 Attachment(s)
Adodc Recordsource (HELP)
good day everyone!
So i made a program that creates a table using a name from textbox and it worked now the problem is in another form where i have a datagrid and a textbox again to show the records that i wanna see in data grid
heres what the forms looks like Attachment 160205
it worked and it shows the data in datagrid but there is a popup Attachment 160207
and this whats inside my adodc Attachment 160209
and heres my code for the entire form (Remember theres nothing wrong with code below the only problem is the code for "Command Text(SQL)
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim display As String
Private Sub Command1_Click()
display = Text1.Text & Space(1) & Text2.Text & Space(1) & Text3.Text
'‘define SQL query
sql = "Select * from [" & display & "]"
'‘specify format of SQL result and assisgn to ADODC
adogrid.CommandType = adCmdText
adogrid.RecordSource = sql
adogrid.Refresh
'‘Display result in the datagrid object
Set DataGrid1.DataSource = adogrid
End Sub
I hope and I wish someone could help me resolve this problem, thank you!!
Re: Adodc Recordsource (HELP)
You show two different sql statements the one in the window is not valid then one in code looks to be ok assuming that display is a string variable that holds the name of a table. If it is an empty var then that too would be invalid
Re: Adodc Recordsource (HELP)
@DataMiser
so what should i do?
Re: Adodc Recordsource (HELP)
> "So i made a program that creates a table using a name from textbox ..."
Bad Idea.
Database != WorkBook.
Table != Spreadsheet.
- If the user enters a name that isn't a valid table name for your database, your application dies.
- If the user enters something "nasty", your application dies.
Obligatory XKCD Reference: Little Bobby Tables - Having created a table, you then need some way of knowing what that table was called. That's generally done by having another table that holds all the table names! It rapidly gets very complicated, making more work for you.
Unless you have a very, very good reason to do so, you should be using a single table for this and the values entered are just fields within that table, for example:
Code:
select * from users ;
+----+------------+------------+-------------+
| id | Last_Name | First_Name | Middle_Name |
+----+------------+------------+-------------+
| 1 | Flintstone | Frederick | Joseph |
| 2 | Flintstone | Wilma | |
+----+------------+------------+-------------+
Regards, Phill W.