Problem to save records

can any one give me sample code to save new records in database using vb 2007


  • [code]
    Dim rstMyDB, conMyConnection, strMyQuery, strFieldOneData, strFieldTwoData, strFieldThreeData

    Set rstMyDB = Server.CreateObject("ADODB.Recordset")
    'Set rstMyDB = CreateObject("ADODB.Recordset") 'use this instead of above line if the code is being run on a local machine

    Set conMyConnection = Server.CreateObject("ADODB.Connection")
    'Set conMyConnection = CreateObject("ADODB.Connection") 'use this instead of above line if the code is being run on a local machine

    strMyQuery = "SELECT * FROM MyTable"

    conMyConnection.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=" & Server.MapPath("MyDB.mdb")

    rstMyDB.Open strMyQuery, conMyConnection
    rstMyDB("MyFieldOne") = strFieldOneData
    rstMyDB("MyFieldTwo") = strFieldTwoData
    rstMyDB("MyFieldThree") = strFieldThreeData


    Hope that helps!!!! Sorry if thats not what you are looking for.
  • Sorry editing this because i posted twice.
  • thank you for reply.
    actually i connect to an access database. i have a code to add data

    Dim workRow As DataRow = workTable.NewRow()
    workRow("CustLName") = "Smith"

    i could not see record in database.
    can you help me.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!