By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

Trying to insert?

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
"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

P: n/a


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

P: n/a
Cor
Hi Dan,
Did you ever see SQLcommandbuilder or OleDBcommandbuilder, that makes every
thing a lot easier?
Cor
Nov 20 '05 #4

P: n/a
"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

P: n/a
"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

P: n/a
>
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 discussion thread is closed

Replies have been disabled for this discussion.