2个回答
展开全部
string strSqlCommand = string.Format("Insert into Users(UserID,Name,Age) values ('{0}','{1}','{2}')",Guid.NewGuid().ToString(),"张三","27")
SqlConnection v_SqlConnection = new SqlConnection("server=Jebel;database=TestDB;uid=sa;pwd=sa");
v_SqlConnection.Open();
SqlCommand v_SqlCommand = new SqlCommand(strSqlCommand,v_SqlConnection);
try
{
v_SqlCommand.ExecuteNonQuery();
}
catch(SqlException se)
{
MessageBox.Show(se.Message);
}
finally
{
v_SqlConnection.Close();
}
SqlConnection v_SqlConnection = new SqlConnection("server=Jebel;database=TestDB;uid=sa;pwd=sa");
v_SqlConnection.Open();
SqlCommand v_SqlCommand = new SqlCommand(strSqlCommand,v_SqlConnection);
try
{
v_SqlCommand.ExecuteNonQuery();
}
catch(SqlException se)
{
MessageBox.Show(se.Message);
}
finally
{
v_SqlConnection.Close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询