Results 1 to 2 of 2

Thread: INSERT in commandtext

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Pilipinas
    Posts
    441

    INSERT in commandtext

    This are my field in my MDB file:

    Field Name Data Type Description
    ===========================================================
    c_id AutoNumber Customer ID [Primary Key]
    c_date Date/Time Current Date [Now]
    c_name Text Customer Name [TextBox1.Text]
    c_mail Text Customer Email [TextBox2.Text]
    ===========================================================

    The only field that I have to update are the "c_name" and "c_mail". And I use this code;


    Dim cn As New OleDbConnection

    Dim cm As New OleDbCommand("INSERT INTO table1 VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "'")

    Dim rd As OleDbDataReader

    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; data source=D:\my.mdb"

    cn.Open()

    cm.Connection = cn

    rd = cm.ExecuteReader()

    cn.Close()


    But this code doesn't work.. Kindly correct this code for me?? What code should I write??

  2. #2
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276

    Re: INSERT in commandtext

    Try changing the query to
    Code:
    INSERT INTO table1(C_name, c_mail) VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "'")
    Jemima.
    "Your worst days are never so bad that you are beyond the reach of God's grace...
    and your best days are never so good that you are beyond the need of God's grace."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width