I have a piece of code that worked when my customer numbers were all numeric. So customer numbers have been added that are alpha now and I get a "The conversion of the nvarchar value ' 4000545398' overflowed an int column. Maximum integer value exceeded" error which I know is over the 2.1million etc... My issue lay in that number 4000545398 is a lot number in the very first record of table shipper_sii [ a nvarchar (10)].
Columns in my tables are as follows...
custaddr - name (nvarchar (60)), cust_num (nvarchar(7))
co - cust_num (nvarchar(7)), co_num (nvarchar(10))
shipper_sii - co_num (nvarchar(10)), lot (nvarchar(15))
my declarations are...
Dim Carton1 As String
Dim dbCustName As String
Dim dbCustNum As String
Anyone have a fix for me? I am scratching my head here... I am pretty sure its in my join, but I am stumped...
' Get Customer Name
Using connObj2 As New SqlClient.SqlConnection("server=Server;database=App;uid=sa;pwd=password;")
Using cmdObj2 As New SqlClient.SqlCommand("SELECT c2.name, c2.cust_num from custaddr as c2 INNER JOIN co as c1 ON (c2.cust_num = c1.cust_num) INNER JOIN shipper_sii as s1 on (c1.co_num = s1.co_num) WHERE lot = " & Carton1, connObj2)
connObj2.Open()
Using readerObj2 As SqlClient.SqlDataReader = cmdObj2.ExecuteReader
'This will loop through all returned records
While readerObj2.Read
dbCustNum = readerObj2("cust_num").ToString
dbCustName = readerObj2("name").ToString
'handle returned value before next loop here
End While
End Using
connObj2.Close()
End Using
End Using
My error pops at the "While readerObj2.Read".
Carton1when you get here? Why don't you use sql-parameter?