project problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aartinair
    New Member
    • Jan 2010
    • 4

    project problem

    hii everybdy.Act now i have removed the data source and added this code,still the data is noty getting inserted
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim myOleDbConnection As OleDb.OleDbConnection
            Dim insertcommand As String
            Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\Radhakrishnan\My Documents\Visual Studio 2008\Projects\BHARATH MATRIMONY\BHARATH MATRIMONY\My Project\REGISTRATIONGROOM.accdb;Persist Security Info=False"
            insertcommand = "INSERT INTO GROOM(MATCH,NAME1,MARITAL STATUS,HEIGHT,AGE,COUNTRY,STATE,CITY,QUALIFICATION,CASTE,RELIGION,MOTHER TONGUE,MOBILE NO,RESIDENCE NO,PHOTO)VALUES (trim(cmbMatch.value),trim(txtName.text),trim(RadioButton.selected.value),trim(txtHeight.text),trim(txtAge.text),trim(cmbCountry.value),trim(cmbState.value),trim(cmbCity.value),trim(txtQualification.text),trim(cmbCaste.value),trim(cmbReligion.value),trim(cmbMotherTongue.value),trim(txtMobile.text),trim(txtResidence.text),picGroom.image)"
            myOleDbConnection = New OleDb.OleDbConnection(connString)
            Dim myOleDbCommand As New OleDb.OleDbCommand(insertcommand, myOleDbConnection)
            myOleDbConnection.Open()
            myOleDbCommand.ExecuteNonQuery()
            myOleDbConnection.Close()
        End Sub
    plz some1 do reply
    Last edited by tlhintoq; Jan 6 '10, 02:35 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Database How two parts 1 and 2

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Your SQL statement is not right.
        Your values, if they are Strings in the database, have to be enclosed in quotes ('').
        A better way to do this is to use parameters (this is demonstrated in part 1 of the "How to use a database in your program" articles)

        -Frinny

        Comment

        Working...