主题:在VC#下建立数据表的问题,加分
如果大家不想看我的程序,就请只看下划线的地方
...........
SqlConnection myConnection;
myConnection=new SqlConnection("server=(local);database=model;Trusted_Connection=yes");
string creatCmd = "create table @youpig (number char(10) not null primary key,more int)";
SqlCommand myCommand = new SqlCommand(creatCmd,myConnection);
[u]myCommand.Parameters.Add(new SqlParameter("@youpig",SqlDbType.NVarChar,10));
myCommand.Parameters["@youpig"].Value=this.textBox1.Text;[/u]
myCommand.Connection.Open();
try
{
myCommand.ExecuteNonQuery();
}
catch(SqlException ex)
{
MessageBox.Show("建立表错误");
}
myCommand.Connection.Close();
..........
这个程序就只有下划线的地方有错误,请教高手应该怎么该,使它运行成功。谢谢
...........
SqlConnection myConnection;
myConnection=new SqlConnection("server=(local);database=model;Trusted_Connection=yes");
string creatCmd = "create table @youpig (number char(10) not null primary key,more int)";
SqlCommand myCommand = new SqlCommand(creatCmd,myConnection);
[u]myCommand.Parameters.Add(new SqlParameter("@youpig",SqlDbType.NVarChar,10));
myCommand.Parameters["@youpig"].Value=this.textBox1.Text;[/u]
myCommand.Connection.Open();
try
{
myCommand.ExecuteNonQuery();
}
catch(SqlException ex)
{
MessageBox.Show("建立表错误");
}
myCommand.Connection.Close();
..........
这个程序就只有下划线的地方有错误,请教高手应该怎么该,使它运行成功。谢谢