Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Dear All
Please help to insert data to my access db,i need code for insert data to msaccess db
i m developing one project in database i m using for msaccess but i am unable to insert below my code posing please help were i m doing mistake.
This is My Code
 
Public Class Party
    Dim cnnOLEDB As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\webapps\ArrowJet\CP.mdb")
    Dim cmdOLEDB As New OleDbCommand
    Dim cmdInsert As New OleDbCommand
    Dim cmdUpdate As New OleDbCommand
    Dim cmdDelete As New OleDbCommand
 
  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        
        Try
            Dim InsertQuery As String
 
            InsertQuery = "INSERT INTO party (PartyName, PartyAccount, PayTo,PartyInfo) VALUES (@PartyName, @PartyAccount, @PayTo,@PartyInfo)"
 
            Dim cmd As OleDbCommand = New OleDbCommand(InsertQuery, cnnOLEDB)
            cmd.Parameters.AddWithValue("@PartyName", ComboBox1.Text)
            cmd.Parameters.AddWithValue("@PartyAccount", paTextBox2.Text)
            cmd.Parameters.AddWithValue("@PayTo", ptTextBox3.Text)
            cmd.Parameters.AddWithValue("@PartyInfo", pfTextBox4.Text)
 
            cnnOLEDB.Open()
            cmdOLEDB = New OleDbCommand(InsertQuery, cnnOLEDB)
            cmdOLEDB.ExecuteNonQuery()
            cnnOLEDB.Close()
        Catch ex As Exception
            MessageBox.Show("Record Added")
 
        End Try
Posted 23-Mar-13 0:29am
Edited 23-Mar-13 0:31am
_duDE_8.1K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 DamithSL 165
4 Tomas Takac 144
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100