error in insert into statement

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2009
Posts: 136
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

error in insert into statement

 
0
  #1
Sep 25th, 2009
m using access 2007 and vb 2005
this is my code
  1. Dim drNewRow As DataRow = m_DataTable.NewRow()
  2. drNewRow("Code") = txtColourCode.Text.Trim
  3. drNewRow("Colour Name") = txtBaseColour.Text.Trim
  4. drNewRow("Price") = txtPrice.Text.Trim
  5.  
  6. m_DataTable.Rows.Add(drNewRow)
  7.  
  8. m_DataAdapter.Update(m_DataTable)
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 307
Reputation: TomW is on a distinguished road 
Solved Threads: 44
TomW TomW is offline Offline
Posting Whiz

Re: error in insert into statement

 
0
  #2
Sep 25th, 2009
That much looks correct, I'm assuming the error is in your actual insert statement connected to your adapter. Can you provide that query? Also add the exact error message that you are receiving.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 136
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

Re: error in insert into statement

 
0
  #3
Sep 25th, 2009
  1. select * from accesstable
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 307
Reputation: TomW is on a distinguished road 
Solved Threads: 44
TomW TomW is offline Offline
Posting Whiz

Re: error in insert into statement

 
0
  #4
Sep 25th, 2009
Thats not an insert query...
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 260
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 50
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: error in insert into statement

 
0
  #5
Sep 25th, 2009
if i have to guess i would say the problem is in this line
drNewRow("Price") = txtPrice.Text.Trim
if the Price is declared as money then you have to convert the txtPrice.text
drNewRow("Price") = Convert.ToDouble(txtPrice.Text.Trim)
but as i said...without any more details its hard to guess.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 136
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

Re: error in insert into statement

 
0
  #6
Sep 26th, 2009
price is declared as text in the database.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 260
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 50
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: error in insert into statement

 
0
  #7
Sep 26th, 2009
then please provide su your Update query. the query you posted is a select query.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 136
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

Re: error in insert into statement

 
0
  #8
Sep 26th, 2009
the data adapter handles my update insert and delete query...
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 19
Reputation: raymyster has a little shameless behaviour in the past 
Solved Threads: 0
raymyster raymyster is offline Offline
Newbie Poster

Re: error in insert into statement

 
-1
  #9
Sep 26th, 2009
why not use ado.net instead?

use commandtext its easier!
Share your knowledge It's one way to achieve immortality.
My Blog: http://blog.rabihtawil.com
My Programming Community: http://www.coderisland.com
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 307
Reputation: TomW is on a distinguished road 
Solved Threads: 44
TomW TomW is offline Offline
Posting Whiz

Re: error in insert into statement

 
0
  #10
Sep 26th, 2009
Originally Posted by babbu View Post
the data adapter handles my update insert and delete query...
The dataadapter does not automatically create any of these commands.

If you are referring to the use of a commandbuilder attached to your dataadapter to generate the insert, update & delete statements; I would like to see the block of coding that creates this and fills your dataadapter so that I may see where it is causing you problems.

Also does the table have a primary key/unique field, the command builder needs this in order to be able to perform these statements.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC