"Miro" <mironagy@golden.netwrote in message
news:u8bkpjJ0GHA.3440@TK2MSFTNGP06.phx.gbl...
Quote:
Yes, that did work perfectly.
>
Im just trying to figure out what you did here.
>
What does the Values (?) mean ?
You'll notice that the text:
INSERT INTO DBVersion (CurVersion) VALUES (?)
is in quotes. It's a parameterized SQL statement that tells Access to
insert a row into the table DBVersion and set the value of the CurVersion
column to the parameterized value (?). The ? is replaced in the statement
with the parameter that is added with the line:
myCommand.Parameters.Add("Param1", OleDbType.VarChar, 50).Value = "2.00"
So it's just a SQL statement, and the ? is a placeholder for the parameter
(the value to insert in this case).
Quote:
and also, what was I doing wrong? ( If i was on the right rack - what
would I be creating this sub for ? )
The route you were taking was to load a DataAdapter first. This basically
uses a dataset to read the data from the table and allow you to manipulate
it in a disconnected fashion. You could make that option work, but unless
you're planning on manipulating existing data and allowing a lot of
disconnected editing/adding/deleting on the table, it's overkill.
For what you want, a simple INSERT of one row into an existing table, the
DataAdapters and DataSets aren't necessary. If you do want to use
DataAdapters and DataSets, it might be best to try adding them to a form to
see the code that's generated. When using the DataAdapter, you have to set
the InsertCommand if you want to insert new rows, and the
UpdateCommand/DeleteCommand properties to update/delete rows.
Quote:
Or better yet, where can I go / what can I google to find examples like
this. ( If you know of any )
http://www.thecodeproject.com has lots of examples. Mostly I work with SQL
Server (not Access), but a lot of the basic concepts are the same. You
might try googling combinations of "OleDb", ".NET", "DataAdapter", "Access",
"DataSets", "sample code", "VB.NET", "InsertCommand".
Quote:
-Thanks for the spelling error - FileDBExtension as I had it Extention.
ahha I did laugh when I seen that.
I wrote the code and then copied the variable all over the place.
No prob :) I assumed it was a typo or a non-American English spelling :)
Quote:
Im sure its a lot easier to do it by "Form" and bind all the tables to
fields on teh form ( i hope ) but Im trying to
figure out how to do it by a function all inbehind the scenes.
Binding it by form is a great way to learn how to use it, since it generates
a lot of code for you automatically. Just bind to the forms and look at the
code generated to get ideas on how it does what it does.
Quote:
"Mike C#" <xyz@xyz.comwrote in message
news:vN4Lg.187$fm1.92@newsfe10.lga...
Quote:
>If you *just* want to add a single row to the database, you're working
>wayyyy too hard. Try something like this:
>>
>Dim myConnectionString As String = _
>"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
>SystemFileDB & FileDBExtension
>Dim myConnection As New OleDbConnection(myConnectionString)
>myConnection.Open()
>Dim myCommand As New OleDbCommand("INSERT INTO DBVersion (CurVersion)
>VALUES (?)", myConnection)
>myCommand.Parameters.Add("Param1", OleDbType.VarChar, 50).Value = "2.00"
>myCommand.ExecuteNonQuery()
>myCommand.Dispose()
>myConnection.Close()
>>
>>
>
>