473,385 Members | 1,492 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,385 software developers and data experts.

Trying to insert?

Hi,

I've got another problem now! Getting "Input string was not in a correct
format"

I have this as my insert command:

myDataAdapter.InsertCommand = connection.CreateCommand()
myDataAdapter.InsertCommand.CommandText = _
"Insert into Suppliers " & _
"(SupplierName, TechnicalContact, SalesContact, OperationsContact,
WorkPhone, FaxNumber" & _
" , Address, City, County, PostalCode, Email, MobilePhone) " & _
"values(&SupplierName, &TechnicalContact, &SalesContact, &OperationsContact,
&WorkPhone, &FaxNumber" & _
", &Address, &City, &County, &PostalCode, &Email, &MobilePhone )"
AddParms(myDataAdapter.InsertCommand, "SupplierName", "TechnicalContact",
"SalesContact", "OperationsContact" _
, "WorkPhone", "FaxNumber", "Address", "City", "County", "PostalCode",
"Email", "MobilePhone")
MsgBox(myDataAdapter.InsertCommand.CommandText)

Followed by:

Dim newRow As DataRow = myDataTable.NewRow()
newRow("SupplierName") = txtSupplierName.Text
newRow("TechnicalContact") = txtTechnicalContact.Text
newRow("SalesContact") = txtSalesContact.Text
newRow("OperationsContact") = txtOperationsContact.Text
newRow("WorkPhone") = txtPhone.Text
newRow("FaxNumber") = txtFax.Text
newRow("Address") = txtAddress.Text
newRow("City") = txtCity.Text
newRow("County") = txtCounty.Text
newRow("PostalCode") = txtPostalCode.Text
newRow("Email") = "BLAR"
newRow("MobilePhone") = txtPhone.Text
Then when i do this:

myDataTable.Rows.Add(newRow)
MsgBox(newRow.ItemArray.Length)
'Update the DB
Try
myDataAdapter.Update(myDataSet, "Suppliers")

I get the error.

Now I can't for the life of me find the problem. I'm not inserting anything
into my key field, but thats autonumber, so this shouldnt matter right?

How can i find the ACTUAL sql that it's having a problem with, I can't seem
to get to it in the debugger.

I've confirmed that the datatable and newrow have the same number of items,
which makes sense...

Any hints on either a fix, or just simply debugging this would be a massive
help! Thanks once again!

Rgds,
Dan
Nov 20 '05 #1
6 990
"Dan Keeley" <ma********@hotmail.com> schrieb
I've got another problem now! Getting "Input string was not in a
correct format"

I have this as my insert command:

myDataAdapter.InsertCommand = connection.CreateCommand()
myDataAdapter.InsertCommand.CommandText = _
"Insert into Suppliers " & _
"(SupplierName, TechnicalContact, SalesContact, OperationsContact,
WorkPhone, FaxNumber" & _
" , Address, City, County, PostalCode, Email, MobilePhone) " & _
"values(&SupplierName, &TechnicalContact, &SalesContact,
&OperationsContact, &WorkPhone, &FaxNumber" & _
", &Address, &City, &County, &PostalCode, &Email, &MobilePhone )"
AddParms(myDataAdapter.InsertCommand, "SupplierName",
"TechnicalContact", "SalesContact", "OperationsContact" _
, "WorkPhone", "FaxNumber", "Address", "City", "County",
"PostalCode", "Email", "MobilePhone")
MsgBox(myDataAdapter.InsertCommand.CommandText)

Why do you use the "&" char for parameters? I thought it's the "@".

More ADO.NET related questions:
microsoft.public.dotnet.framework.adonet

--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #2


Why do you use the "&" char for parameters? I thought it's the "@".


Indeed it should be, so I changed that and still get the same message....

Maybe it's not even getting that far? Anyone any further hints on debugging
this?
Nov 20 '05 #3
Cor
Hi Dan,
Did you ever see SQLcommandbuilder or OleDBcommandbuilder, that makes every
thing a lot easier?
Cor
Nov 20 '05 #4
"Cor" <no*@non.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi Dan,
Did you ever see SQLcommandbuilder or OleDBcommandbuilder, that makes every thing a lot easier?
Cor


Excellent that works and so much easier!!!

now why didnt oreilly spot that!!

Thanks very much
Dan
Nov 20 '05 #5
"Dan Keeley" <ma********@hotmail.com> schrieb
"Cor" <no*@non.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi Dan,
Did you ever see SQLcommandbuilder or OleDBcommandbuilder, that
makes

every
thing a lot easier?
Cor


Excellent that works and so much easier!!!

now why didnt oreilly spot that!!


Before posting my first reply, I used your code to have the string built,
but I didn't see an error in the resulting SQL string. Did you find out why
the error occured meanwhile?
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #6
>
Before posting my first reply, I used your code to have the string built,
but I didn't see an error in the resulting SQL string. Did you find out why the error occured meanwhile?
--

No, afraid not, Im still confused as to why it didnt work.
Nov 20 '05 #7

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

Similar topics

10
by: sparks | last post by:
So far I have tried the microsoft version of this, and lost the table LOl so I tried this way to write to two tables carrying over the autoid but so far I can not get the autonumber and put it in...
1
by: Curt Emich | last post by:
I'm trying to insert a new record into an MS Access table. The code below compiles and runs, but it doesn't write a record into the table. Can someone tell me why? Dim thisSelectCommand As...
1
by: Henry | last post by:
Hi. I've been trying to modify my dataset and have been unsucessful. Any help would be great. What I have is a dataset in a session variable. Here is what I have done to stored into the dataset...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
by: Andrew | last post by:
I hope this doesn't sound too silly. I am trying to cache a datatSet. I have written the code below. I insert into the cache: Eg. i = 1. if (Cache == null) { Cache.Insert("testQuestion"+ i,...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
1
by: Scott.Ashby | last post by:
I'm trying to insert literal data containing #, like so: insert into table1 values ('fld#1') and Access is barfing on the pound sign. Is there some sort of escape character I can use to...
10
by: teddysnips | last post by:
SQL Server 2000 (DDL below) If I try to run this code in QA: SET IDENTITY_INSERT tblAdminUsers ON INSERT INTO tblAdminUsers (fldUserID, fldUsername, fldPassword, fldFullname,
5
by: alivip | last post by:
How can I get every Token (word) and PreviousToken(Previous word) From multube files and frequency of each two word my code is trying to get all single word and double word (every Token (word) and...
6
by: pbd22 | last post by:
Hi. I am trying to insert a zero into the below table and I am being told that: Cannot insert the value NULL into column 'UsageToday', table DB.dbo.Pub_Count'; column does not allow nulls....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.