473,382 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Inserting A New Record

Can someone tell me specifically what's missing in this code so that it
won't write the record into the database? Please, no references to lengthy,
bloated, meandering articles telling me how to make a watch when I'm merely
asking what time it is.

Dim thisDataAdapter As OleDb.OleDbDataAdapter = New
OleDb.OleDbDataAdapter("SELECT * FROM Sessions", OleDbConnection1)

thisDataAdapter.InsertCommand = New OleDb.OleDbCommand("INSERT INTO Sessions
SET Notes = ? ", OleDbConnection1)

thisDataAdapter.InsertCommand.Parameters.Add("Note s", OleDbType.VarChar, 15,
"Notes")

' Dim workParm As OleDbParameter =
catDA.UpdateCommand.Parameters.Add("@CategoryID", OleDbType.Integer)

' workParm.SourceColumn = "CategoryID"

' workParm.SourceVersion = DataRowVersion.Original

Dim thisDataset As DataSet = New DataSet()

thisDataAdapter.Fill(thisDataset, "Sessions")

Dim thisTable As New DataTable()

thisTable = thisDataset.Tables("Sessions")

Dim cRow As DataRow = thisTable.NewRow()

cRow("Notes") = "Yadda"

thisTable.Rows.Add(cRow)

thisDataAdapter.Update(thisDataset)

Nov 20 '05 #1
3 1117
Curt,

The logic of the table assignment is backwards. You're trying to update the
permanent table 'sessions' but you're actually updating the temporary table
'thistable'.

Do this instead:
crow = thisdataset.Tables(0).NewRow()

etc.

HTH,

Bernie Yaeger

"Curt Emich" <ce****@comcast.net> wrote in message
news:1b********************@comcast.com...
Can someone tell me specifically what's missing in this code so that it
won't write the record into the database? Please, no references to lengthy, bloated, meandering articles telling me how to make a watch when I'm merely asking what time it is.

Dim thisDataAdapter As OleDb.OleDbDataAdapter = New
OleDb.OleDbDataAdapter("SELECT * FROM Sessions", OleDbConnection1)

thisDataAdapter.InsertCommand = New OleDb.OleDbCommand("INSERT INTO Sessions SET Notes = ? ", OleDbConnection1)

thisDataAdapter.InsertCommand.Parameters.Add("Note s", OleDbType.VarChar, 15, "Notes")

' Dim workParm As OleDbParameter =
catDA.UpdateCommand.Parameters.Add("@CategoryID", OleDbType.Integer)

' workParm.SourceColumn = "CategoryID"

' workParm.SourceVersion = DataRowVersion.Original

Dim thisDataset As DataSet = New DataSet()

thisDataAdapter.Fill(thisDataset, "Sessions")

Dim thisTable As New DataTable()

thisTable = thisDataset.Tables("Sessions")

Dim cRow As DataRow = thisTable.NewRow()

cRow("Notes") = "Yadda"

thisTable.Rows.Add(cRow)

thisDataAdapter.Update(thisDataset)

Nov 20 '05 #2


Thanks. Yeah, I caught that a while ago, but still nothing. I went to
this link

http://www.dotnetextreme.com/code/BasicAdo.asp

and copied the code verbatim and still don't get a new record. I'm
starting to wonder about my connection.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Hi Curt,

Try, for starters, using a simple commandbuilder, as in this very direct and
simple code snippet:
Dim davwbillex As New SqlDataAdapter("select * from vwbillex", oconn)

Dim dsvwbillex As New DataSet("vwbillex")

davwbillex.Fill(dsvwbillex, "vwbillex")

Dim commandbuilder_vwbillex As SqlCommandBuilder = New
SqlCommandBuilder(davwbillex)

mrow = dsvwbillex.Tables(0).NewRow()

mrow("retcode") = "54901"

mrow("inv_dt") = Date.Now.Date

dsvwbillex.Tables("vwbillex").Rows.Add(mrow)

Try

davwbillex.Update(dsvwbillex, "vwbillex")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

If this works ok (you'll need, of course, a table with this structure), then
there's nothing wrong with the connection.

Let me know.

Regards,

Bernie

"Curt Emich" <ce****@comcast.net> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...


Thanks. Yeah, I caught that a while ago, but still nothing. I went to
this link

http://www.dotnetextreme.com/code/BasicAdo.asp

and copied the code verbatim and still don't get a new record. I'm
starting to wonder about my connection.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick | last post by:
Is there a way to reference the 'primary key' field of a record you are actually inserting at the moment. Im using an 'int auto increment' field as the primary key. I could reference it with a...
4
by: FangQ | last post by:
hi I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index...
7
by: ebindia0041 | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, Asp.net 1.1 with c# I'm inserting simple records into a table. But one...
3
by: veerapureddy | last post by:
Hai everybody, i like to insert some records into database from html form by entering data.my problem is how can i check , whether a record is available in database about a particular...
5
by: bob44 | last post by:
Hi, I recently created a mysql database using phpmyadmin. I then proceeded to make a form to insert data into the database, but the problem is that the form is only able to insert one record, and...
20
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt...
2
by: Question123 | last post by:
Hi i have one database table Table1.which contains almost 20000000 recordes. record to this table are inserted through storedprocedure. storedprocedure takes parameter as "value", Beginningdate,...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
2
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.