#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Canada
    Posts
    19
    Rep Power
    0

    unknown column value


    I have problems inserting the values.

    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

    phone_value = "555-555"
    name_value = "test"

    conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=phone_number;UID=root;PWD=legend;"
    conn.CursorLocation = adUseClient
    conn.Open

    '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
    Last edited by sparkrulez; January 17th, 2003 at 01:47 PM.
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    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.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Canada
    Posts
    19
    Rep Power
    0

    it has to be 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
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    Oh, sorry, I misunderstood you.
    In you sql statement you have to surround your variables in single quotes.
    i.e.
    Code:
    dim sql = "INSERT INTO phone_1(phone_number, name_id) values('" & phone_value  & "', '" & name_value & "')"
    conn.Execute sql
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Canada
    Posts
    19
    Rep Power
    0

    AWESOME


    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...

    :-)
  10. #6
  11. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    not a problem, we all start somewhere.

IMN logo majestic logo threadwatch logo seochat tools logo