Raziyeh Karimi

Raziyeh Karimi

  • NA
  • 5
  • 8.2k

sting and varchar

May 7 2013 6:51 AM
 

private void ExecuteInsert(string us, string ps)

{

us = TextBox1.Text;

ps = TextBox2.Text;

SqlConnection conn = new SqlConnection(GetConnectionString());

SqlCommand cmd = new SqlCommand("INSERT INTO log" + "( us,ps)"

+

"values" + " (@us,@ps)");

try

{

conn.Open();

cmd.Parameters.Add(

new SqlParameter(@us, SqlDbType.VarChar, 20).Value = us);

cmd.Parameters.Add(

new SqlParameter(@ps, SqlDbType.VarChar, 20).Value = ps);

cmd.CommandType =

CommandType.Text;

cmd.ExecuteNonQuery();

}how can convert string to varchar



 

 


Answers (2)