Note that there are some explanatory texts on larger screens.

plurals
  1. POExtract value from string collection
    text
    copied!<p>I have a string collection like this</p> <pre><code>SetDEL_Stores.Add(DealerCode + "," + ItemIdentityCode.Text + "," + decimal.Parse(Qty.Text) + "," + DateTime.ParseExact(ExpireDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture) + "," + BatchNumber.Text); InsertDEL_Stores(SetDEL_Stores); </code></pre> <p>after pass values to the <code>SetDEL_Stores</code> (my string collection), collection is</p> <pre><code>"S0010M,AZI002M,3,12/26/2013 12:00:00 AM,VDIQ20" </code></pre> <p>in this case I'm using one value from this collection, as a parameter with SQL query</p> <pre><code> private void InsertDEL_Stores(StringCollection SC_PurLinr) { String strConnString = ConfigurationManager.ConnectionStrings["CBConnectionString"].ConnectionString; const String strQuery = "SELECT BatchNumber FROM DEL_Stores WHERE BatchNumber = @BatchNumber"; SqlConnection conPR = new SqlConnection(strConnString); SqlCommand cmdPR = new SqlCommand(); cmdPR.Parameters.AddWithValue("@BatchNumber", SC_PurLinr.IndexOf("4")); cmdPR.CommandType = CommandType.Text; cmdPR.CommandText = strQuery; cmdPR.Connection = conPR; conPR.Open(); SqlDataReader sdr = cmdPR.ExecuteReader(); while (sdr.Read()) { TextBox1.Text = sdr["BatchNumber"].ToString(); } conPR.Close(); conPR.Dispose(); } </code></pre> <p>After execution I'm getting an error </p> <blockquote> <p>Conversion failed when converting the nvarchar value 'VDIQ20' to data type int.</p> </blockquote> <p>It points to the line</p> <pre><code>while (sdr.Read()) </code></pre> <p>But if I set the parameter like <code>cmdPR.Parameters.AddWithValue("@BatchNumber", "VDIQ20");</code> as normal I can take the correct value to expected textbox</p> <p>What can I do to fix this problem? Please help me ..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload