This is an ado connection to a sql database... the code works..except it doesn't put the name value or the phone value in the database... when i replace the variables with 'field1', 'field2' it works... but what I need to do is have it insert actual fields, since the fields are always changing...
--------------
Private Sub Command1_Click()
Dim phone_value As String
Dim name_value As String
Dim conn As New ADODB.Connection
'direct insert [this is the part that's giving me the hard-time]
conn.Execute "INSERT INTO phone_1(phone_number, name_id) values(phone_value,name_value)"
End Sub
----------------
thanks in advance
As far as I know you cannot do what you are trying to do.
What it sounds like you want is a view, but unfortunately is not currently possible with mysql.
You might check the mysql documentation and see, but I don't believe it is possible.
I want to insert
phone_value = "555-555"
name_value = "test"
into my database
when i try
conn.Execute "INSERT INTO phone_1(phone_number, name_id) values('555-555','test')"
it works...but when i try
conn.Execute "INSERT INTO phone_1(phone_number, name_id) values(phone_value,name_value)"
it does not work
Oh, sorry, I misunderstood you.
In you sql statement you have to surround your variables in single quotes.
i.e.
dim sql = "INSERT INTO phone_1(phone_number, name_id) values('" & phone_value & "', '" & name_value & "')"
conn.Execute sql
No problems, I probably just explained it all wrong...
that's what I was looking for. Thanks for taking the time to give a newbie a hand...