Server
Management
Studio,连接上SQL服务器,点左上角的新建查询就可以打开输入脚本的窗口了
insert
into
表名(字段名,字段名)
values(值,值)
请按下列写法拼接sql语句:strSql = "insert into TBLKAZUATE ([name],score,[day]) " _
&" values ('" &txtNam.Text _
&"', CONVERT(int, '" &lblNum.Text _
&"'), GETDATE())"
SqlConnection conn = nullSqlCommand cmd = null
string sql = "insert into t_student(name,age) values(@name,@age)"
try
{
String connString = @"IntegratedSecurity=SSPIDatabase=myexampleServer=localhost\sqlexpress"
conn = new SqlConnection(connString)
conn.Open()
cmd = new SqlCommand(sql,conn)
cmd.ExecuteNonQuery()
cmd.Parameters.Add("@name","jack")
cmd.Parameters.Add("@age",21)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)