String or binary data would be truncated. ASP VB.NET

The error is being thrown at the insert statement below, where the dose_str field or column in the database table has, for example, the value “Dose Strength is 200.” But this is getting split into columns, translated to the following
SQL statement that I got from the SQL Profiler:

insert into web_ship_detail (web_order_id, line_id, no_of_participants, Amt_inventory, NSC_num, dose_str, dose_unit, dose_form, dose_mult, amt_req) values (123,'B',0,0,900096,'Dose','strength', 'i', '200', 1)

However, what I want is to insert the value "Dose strength is 200" as one value for Does_str column.
I am not sure how to change the command in order to do that.

The data type for each column is :
web_order_id numeric(6, 0)
line_id char(1)
no_of_participants numeric(6, 0)
Amt_inventory numeric(6, 0)
NSC_num numeric(6, 0)
Dose_str varchar(20)
Dose_unit varchar(2)
Dose_form varchar(1)
Dose_mult varchar(10)
amt_req numeric(6, 0)
amt_shipped numeric(6, 0)

None of them allows null except Dose_Mult and amt_shipped.
-

   myCommand.CommandText = "insert into web_ship_detail (web_order_id, line_id, no_of_participants, Amt_inventory, NSC_num, dose_str, dose_unit, dose_form, dose_mult, amt_req) values (" & webOrderID & ",'" & obj.lineItem1.ToString & "'," & obj.NoOfParticipants1.ToString & "," & obj.AmtInInventory1.ToString & "," & obj.NSCNumber1.ToString & ",'" & obj.DoseStrength1.ToString & "','" & obj.DoseUnit1.ToString & "', '" & obj.DoseForm1.ToString.Substring(0, 1) & "', '" & obj.DoseMult1.ToString & "', " & obj.AmtRequested1.ToString & ")"

Below is the entire method:

        For Each de As DictionaryEntry In GetCart()
            Dim obj As OrderLineItem = CType(de.Value, OrderLineItem)
            myCommand.CommandText = "insert into web_ship_detail (web_order_id, line_id, no_of_participants, Amt_inventory, NSC_num, dose_str, dose_unit, dose_form, dose_mult, amt_req) values (" & webOrderID & ",'" & obj.lineItem1.ToString & "'," & obj.NoOfParticipants1.ToString & "," & obj.AmtInInventory1.ToString & "," & obj.NSCNumber1.ToString & ",'" & obj.DoseStrength1.ToString & "','" & obj.DoseUnit1.ToString & "', '" & obj.DoseForm1.ToString.Substring(0, 1) & "', '" & obj.DoseMult1.ToString & "', " & obj.AmtRequested1.ToString & ")"
            myCommand.ExecuteNonQuery()
        Next de
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories