Thread: Error converting data type varchar to float
Started 1 month, 1 week ago by tracmonali
Hello, I get this error "Error converting data type varchar to float at System.Data.SqlClient.SqlConnection" when I am running an Insert stmt. This is the code:
Protected Sub BUCreatePIR_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BUCreatePIR.Click Dim InsertSQL As String = "" InsertSQL = "Insert into Main_table(Sold_To_#, Sold_To_Name, Sold...
On a side note, you code is begging for a SQL injection... You should really be using SqlParameters for this see http://msdn.microsoft.com/en-us/library/system.dat a.sqlclient.sqlparameter.aspx . To answer your question, what are your data types for the Table? One of your data types is not matching, can you post the rest of the Stack? Hope this helps, --Scott...
Hi,
While inserting data in database we have ensure that data type of all the columns and values that we are inserting should match. Please check whether you are passing values with proper data type or not.
Leena, My insert code works perfect when I run it exclusively. One of the fields SoldTo#, when inserted by user, populates other 4 textboxes. But with the TBCustNoSoldTo_TextChanged event, it also triggers the click button event; which I do not wish to happen. The user must fill rest of the fields and then explicitly click the button. It is then I wish to run the click button event and ...
Thanks Tusharrs, I checked the no of parameters. PLease read my post written to Leena. I found solution, a work around. Thanks for everybody's responses.
hello, you mean this query runs Insert into Main_table (Sold_To_#, Sold_To_Name,
Sold_To_Address, Sold_To_City, Sold_To_State, Sold_To_Zip, Bolt_#,
Product_Category, Issue_or_Complaint) Select '' as Sold_To_#, '' as 'Sold_To_Name', '' as Sold_To_Address, '' as Sold_To_City, '' as Sold_To_State, " as Sold_To_Zip,...
This runs fine Tushar.
Protected Sub BUCreatePIR_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BUCreatePIR.Click Dim InsertSQL As String = "" InsertSQL = "Insert into Main_table(Sold_To_#, Sold_To_Name, Sold_To_Address, Sold_To_City, Sold_To_State, Sold_To_Zip,Bolt_#, Product_Category, Issue_or_Complaint) Select " InsertSQL += "'" & ...
This runs fine Tushar. Protected Sub BUCreatePIR_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BUCreatePIR.Click Dim InsertSQL As String = "" InsertSQL = "Insert into...
On a side note, you code is begging for a SQL injection... You should really be using SqlParameters for this see http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx . To answer your question, what are your data types for the Table? One of your data types is not matching, can you post the rest of the Stack? Hope this helps, --Scott
Hi, While inserting data in database we have ensure that data type of all the columns and values that we are inserting should match. Please check whether you are passing values with proper data type or not.
Thread profile page for "Error converting data type varchar to float" on http://www.asp.net.
This report page is a snippet summary view from a single thread "Error converting data type varchar to float", located on the Message Board at http://www.asp.net.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity