I'm connecting to an access database locally on my
computer. I am using the CommandBuilder because I read
that it provides a mechanism to automatically generate
commands used to facilitate the updates made in an
OleDbDataSet to the corresponding table. If you give me
some points as to where the problem is occuring and why
it occurs that would be appreciated. Unfortunately I've
been told that this is not the right group to post. My
email to reply is
skourdes@hotmail.com
thanks
Samy[color=blue]
>-----Original Message-----
>What database are you connecting to? Also, why do you[/color]
call this line of code[color=blue]
>readwrite.InsertCommand = CmdBuilder.GetInsertCommand()?
>
>
>--
>Carsten Thomsen
>
>Enterprise Development with VS .NET, UML, and MSF
>
http://www.apress.com/book/bookDisplay.html?bID=105
>"Samy K" <skourdes@hotmail.com> wrote in message
>news:341101c3757a$b39c4a10$a101280a@phx.gbl...[color=green]
>> I'm having a bit of problems entering a new row to an
>> access database and what I would like to know is do I[/color][/color]
have[color=blue][color=green]
>> to assign certain values in my INSERT INTO SQL[/color][/color]
statement.[color=blue][color=green]
>> I have read about the commandbuilder and it said that[/color][/color]
the[color=blue][color=green]
>> insert command is automatically generated. Below is my
>> code. Can someone help me out into where the syntax[/color][/color]
error[color=blue][color=green]
>> is happening:
>>
>> Dim readwrite As OleDb.OleDbDataAdapter
>> Dim CmdBuilder As OleDb.OleDbCommandBuilder
>> Dim ds As DataSet = New DataSet()
>> Dim table As DataTable
>> Dim row As DataRow
>>
>> 'sqlstring is global variable with[/color][/color]
string "Select[color=blue][color=green]
>> * from inv_compt_invest"
>> readwrite = New OleDb.OleDbDataAdapter[/color][/color]
(sqlstring,[color=blue][color=green]
>> dbInventaire)
>> CmdBuilder = New OleDb.OleDbCommandBuilder
>> (readwrite)
>> readwrite.InsertCommand =
>> CmdBuilder.GetInsertCommand()
>> MsgBox(readwrite.InsertCommand.CommandText)
>> Try
>> readwrite.Fill(ds, "inv_compt_invest")
>>
>> 'output data from dataset
>> table = ds.Tables.Item(0)
>> If table.Rows.Count <> 0 Then
>>
>> 'Enter new records
>> If newdataentry = True Then
>> row = table.NewRow()
>> row("Date d'acquisition") = CDate
>> (TextBox2.Text)
>> row("Num de Compte") = CInt
>> (TextBox3.Text)
>> row("Designation de l'article") =
>> TextBox4.Text
>> row("Quantite") = CInt[/color][/color]
(TextBox5.Text)[color=blue][color=green]
>> row("Fournisseur") = TextBox6.Text
>> row("Num de la facture") =
>> TextBox7.Text
>> row("Marque") = TextBox8.Text
>> row("Localisation") = TextBox9.Text
>> table.Rows.Add(row)
>>
>> 'Update the database table
>> readwrite.Update
>> (ds, "inv_compt_invest") 'The exception gets triggered
>> here through debugging
>> newdataentry = False
>> Else
>> MsgBox("Need to enter new data to[/color][/color]
save[color=blue][color=green]
>> to Database")
>> End If
>> End If
>> Catch ex As Exception
>> MsgBox(ex.Message)
>> End Try
>>
>> thanks,
>>
>> Sam[/color]
>
>
>.
>[/color]