I am working on project where i am inserting productid into one of table.But here is something strange. If productid is like(002374) then in table its saving like(2374),missing leading zeros.
I have checked variable fetching correct productid(002374). Datatype of column is nvarchar(255). And productid variable is of string type.
It looks something wrong with datatype or different thing.
Here is my code:
productid = dt.Rows(i)(3)
item = dt.Rows(i)(0)
amount = dt.Rows(i)(1)
qty = dt.Rows(i)(2)
Custid = Session("customerid")
Total = Session("price")
Notes = Session("Notes")
Dim con1 As New Data.SqlClient.SqlConnection
con1.ConnectionString = ConfigurationManager.ConnectionStrings("ConnStringDb1").ConnectionString
Dim strConnString1 As String = ""
strConnString1 &= "INSERT INTO Weborder_Details (OrderID,Qty,Cost,UnitPrice,ProductID,ItemDescription) VALUES ('" & result2 & "','" & qty & "', " & amount & "," & amount & "," & productid & ",'" & item & "'); "
Dim cmd2 As SqlClient.SqlCommand = New SqlClient.SqlCommand(strConnString1, con1)
con1.Open()
cmd.Connection = con1
cmd.CommandType = CommandType.Text
cmd2.ExecuteNonQuery()
Please tell me what i need to solve this issue.