|
-
Nov 13th, 2007, 10:26 AM
#1
Thread Starter
KING BODWAD XXI
ADO.net in Vb.net OLEDBCommandBuilder problem
-
Nov 13th, 2007, 10:37 AM
#2
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
It has to do with the Select.... the command builders use the SELECT statement to work up the insert/update/delete commands.... the problem is your where clause.... I'm willing to bet that if you took out the "WHERE [ID] =" bits it'll work...
What I suspect is happening is that the "WHERE [ID] =" gets included in the insert (since it was part of the insert).... and that's an invalid syntax on INSERT....
-tg
-
Nov 13th, 2007, 10:46 AM
#3
Thread Starter
KING BODWAD XXI
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
Thanks but it didnt work 
Would it have anything to do with the fact there is an Autonumber in that table. I am assuming that it will automatically do that number
-
Nov 13th, 2007, 10:55 AM
#4
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
It is defined as the PKey? ... Hmm.... not sure that's the problem either...that would be a constraint error, not a syntax....
Umm... try this... before doing an update.... MEssageBox.Show DataConnector.InsertCommand.ToString ..... see what comes out....
-tg
-
Nov 13th, 2007, 11:10 AM
#5
Lively Member
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
This is how I did this...note that the table must have a primary key or the command builder will not work. My table has the [ID] field as PK and Autonumber.
Code:
Private Sub Fill_DataGrid()
Dim connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sAppPath & "Drawings.mdb;Persist Security Info=False")
adapter.SelectCommand = New OleDbCommand("SELECT * FROM " + GridSource, connection)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(adapter)
connection.Open()
table.Clear()
adapter.Fill(table)
DataGrid.DataSource = table
builder.GetUpdateCommand()
connection.Close()
End Sub
-
Nov 13th, 2007, 11:13 AM
#6
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
The Autonumber field isn't a problem. The problem is that you have used keywords as fieldnames (name, password). Get the Builder to surround fieldnames with a delimiter.
'Allow changes to occur
Builder = New OleDbCommandBuilder(DataConnector)
Builder.QuotePrefix = "["
Builder.QuoteSuffix = "]"
-
Nov 13th, 2007, 11:21 AM
#7
Thread Starter
KING BODWAD XXI
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
ooo that just raises the error
'Object reference not set to an instance of an object.'
on the line of code added :s
Now I have to work out whats not set and how to set it
-
Nov 13th, 2007, 12:52 PM
#8
Re: ADO.net in Vb.net OLEDBCommandBuilder problem
ooo that just raises the error
Which code raised the error?
-
Nov 14th, 2007, 02:56 AM
#9
Thread Starter
KING BODWAD XXI
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|