Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,038 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,583 people online right now. Registration is fast and FREE... Join Now!




Updating Data

 
Reply to this topicStart new topic

Updating Data, Getting syntax error INSERT INTO statement

rajeev_kbg
6 Mar, 2008 - 12:23 AM
Post #1

New D.I.C Head
*

Joined: 4 Oct, 2007
Posts: 1


My Contributions
CODE
Imports System.Data.OleDb
Public Class Form1
    Dim das1 As New DataSet
    Dim dap1 As New OleDbDataAdapter()

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim cnn1 As _
               System.Data.OleDb.OleDbConnection = _
               ConnectToNorthwind()

       Dim str1 As String = "SELECT * FROM ReqDetails"
        Dim cmd1 As _
            New System.Data.OleDb.OleDbCommand( _
            str1, cnn1)

              dap1.SelectCommand = cmd1

              Dim cmb1 As New _
            OleDbCommandBuilder()
        cmb1 = _
            New OleDbCommandBuilder(dap1)

            dap1.Fill(das1, "Shippers")
        With DataGrid1

            .DataSource = das1.Tables("Shippers")
        End With

    End Sub
    Function ConnectToNorthwind() As OleDbConnection
      im str1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\JBB\My Documents\NSReq.mdb;Persist Security Info=False"
        Dim cnn1 As New OleDbConnection
        cnn1.ConnectionString = str1
        Return cnn1
    End Function

    Private Sub bttnPopulate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnPopulate.Click
            das1.Tables("Shippers").Clear()
            Me.DataGrid1.DataSource = Me.das1.Tables("Shippers")

               dap1.Fill(das1, "Shippers")

    End Sub

    Private Sub bttnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnModify.Click
             dap1.Update(das1, "Shippers")
    End Sub

  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dRow As DataRow = Me.das1.Tables("Shippers").NewRow()
        dRow("ReqNumber") = "Farooq"
        dRow("Date") = "55858"
               das1.Tables("Shippers").Rows.Add(dRow)
             dap1.Update(das1, "Shippers")
    End Sub
End Class

User is offlineProfile CardPM
+Quote Post

bhandari
RE: Updating Data
6 Mar, 2008 - 12:46 AM
Post #2

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
Explain your problem and please use code.gif
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Updating Data
6 Mar, 2008 - 10:52 AM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Post the exact error message that you are getting.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:48PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month