473,788 Members | 2,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.I nsertCommand = connection.Crea teCommand()
myDataAdapter.I nsertCommand.Co mmandText = _
"Insert into Suppliers " & _
"(SupplierN ame, TechnicalContac t, SalesContact, OperationsConta ct,
WorkPhone, FaxNumber" & _
" , Address, City, County, PostalCode, Email, MobilePhone) " & _
"values(&Suppli erName, &TechnicalConta ct, &SalesContac t, &OperationsCont act,
&WorkPhone, &FaxNumber" & _
", &Address, &City, &County, &PostalCode, &Email, &MobilePhone )"
AddParms(myData Adapter.InsertC ommand, "SupplierNa me", "TechnicalConta ct",
"SalesConta ct", "OperationsCont act" _
, "WorkPhone" , "FaxNumber" , "Address", "City", "County", "PostalCode ",
"Email", "MobilePhon e")
MsgBox(myDataAd apter.InsertCom mand.CommandTex t)

Followed by:

Dim newRow As DataRow = myDataTable.New Row()
newRow("Supplie rName") = txtSupplierName .Text
newRow("Technic alContact") = txtTechnicalCon tact.Text
newRow("SalesCo ntact") = txtSalesContact .Text
newRow("Operati onsContact") = txtOperationsCo ntact.Text
newRow("WorkPho ne") = txtPhone.Text
newRow("FaxNumb er") = txtFax.Text
newRow("Address ") = txtAddress.Text
newRow("City") = txtCity.Text
newRow("County" ) = txtCounty.Text
newRow("PostalC ode") = txtPostalCode.T ext
newRow("Email") = "BLAR"
newRow("MobileP hone") = txtPhone.Text
Then when i do this:

myDataTable.Row s.Add(newRow)
MsgBox(newRow.I temArray.Length )
'Update the DB
Try
myDataAdapter.U pdate(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 1005
"Dan Keeley" <ma********@hot mail.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.I nsertCommand = connection.Crea teCommand()
myDataAdapter.I nsertCommand.Co mmandText = _
"Insert into Suppliers " & _
"(SupplierN ame, TechnicalContac t, SalesContact, OperationsConta ct,
WorkPhone, FaxNumber" & _
" , Address, City, County, PostalCode, Email, MobilePhone) " & _
"values(&Suppli erName, &TechnicalConta ct, &SalesContac t,
&OperationsCont act, &WorkPhone, &FaxNumber" & _
", &Address, &City, &County, &PostalCode, &Email, &MobilePhone )"
AddParms(myData Adapter.InsertC ommand, "SupplierNa me",
"TechnicalConta ct", "SalesConta ct", "OperationsCont act" _
, "WorkPhone" , "FaxNumber" , "Address", "City", "County",
"PostalCode ", "Email", "MobilePhon e")
MsgBox(myDataAd apter.InsertCom mand.CommandTex t)

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

More ADO.NET related questions:
microsoft.publi c.dotnet.framew ork.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 SQLcommandbuild er or OleDBcommandbui lder, that makes every
thing a lot easier?
Cor
Nov 20 '05 #4
"Cor" <no*@non.com> wrote in message
news:uy******** ******@tk2msftn gp13.phx.gbl...
Hi Dan,
Did you ever see SQLcommandbuild er or OleDBcommandbui lder, 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********@hot mail.com> schrieb
"Cor" <no*@non.com> wrote in message
news:uy******** ******@tk2msftn gp13.phx.gbl...
Hi Dan,
Did you ever see SQLcommandbuild er or OleDBcommandbui lder, 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
1453
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 the other table. thanks big time for any help maybe I tried to do it the dumb way but it looks to me like this should work probably not :)
1
946
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 New OleDb.OleDbCommand("SELECT * FROM Sessions", Me.OleDbConnection1) Dim thisDataAdapter As New OleDb.OleDbDataAdapter(thisSelectCommand) Dim thisDataset As New System.Data.DataSet()
1
2919
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 via store procedure. Sample Stored Procedure: CREATE PROCEDURE prcGetData AS
25
4074
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
1584
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, ds.Tables); }
5
3791
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 List<RoleData> GetRoles() { return GetRoles(null, false); }
1
1324
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 prefix the # so it will accept it (or some similar workaround)? Thanks,
10
8221
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
2540
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 PreviousToken(Previous word)) from multube files and get frequency of both. it can get for single word but double word give error line 50, in most_frequant_word word1+= ' ' + word_list IndexError: list index out of range import...
6
1829
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. UPDATE fails. The statement has been terminated. What I am trying to insert is a string that I convert into an int
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.