当数据类型是int时,insert语句怎么写呢..........
数据库是sql server 2000
数据表table1有3个列 序号(int) 标题(nvarchar) 内容(nvarchar)
现在想插入一行
insert into table1(序号,标题,内容) values('"+bianhao+"','"+textbox1.text+"','"+textbox2.text+"')
失败了....
insert into table1(序号,标题,内容) values("+bianhao+",'"+textbox1.text+"','"+textbox2.text+"')
也失败...
bianhao是个interger型变量
格式应该怎样呢.
[解决办法]
序号有自增长吗? 有的话不需要手动插入. 没有的话,bianhao.ToString()
[解决办法]
insert into table1(序号,标题,内容) values("& bianhao &",'" & textbox1.text+ & "','" & textbox2.text & "')
[解决办法]
insert into table1(序号,标题,内容) values("+bianhao+","+"'"+textbox1.text+"'"+","+"'"+textbox2.text+"'")
试试.
在这之前你首先要保证biaohao为int型数据.
[解决办法]
dim strSql as stringstrSql = " insert into table1(序号,标题,内容) "strSql =strSql & " values("& bianhao &",'" & textbox1.text & "','" & textbox2.text & "') "
[解决办法]
插入数据不用参数就慢慢拼吧..
[解决办法]
建立楼主最好改为用参数的方式:
Dim DataParm(16) As SqlParameter
DataParm(0) = New SqlParameter("@MGOKDCD", SqlDbType.Char)
DataParm(1) = New SqlParameter("@MGOGOID", SqlDbType.Char)
DataParm(2) = New SqlParameter("@MGOCTNB", SqlDbType.Char)
DataParm(3) = New SqlParameter("@MGOCTGR", SqlDbType.VarChar)
DataParm(4) = New SqlParameter("@MGOGONM", SqlDbType.VarChar)
DataParm(5) = New SqlParameter("@MGOUSNM", SqlDbType.VarChar)
DataParm(6) = New SqlParameter("@MGOSIZE", SqlDbType.VarChar)
DataParm(7) = New SqlParameter("@MGOALNB", SqlDbType.Int)
DataParm(8) = New SqlParameter("@MGOALDY", SqlDbType.Int)
DataParm(9) = New SqlParameter("@MGOZNUM", SqlDbType.Int)
DataParm(10) = New SqlParameter("@MGOINUM", SqlDbType.Int)
DataParm(11) = New SqlParameter("@MGOCMNM", SqlDbType.VarChar)
DataParm(12) = New SqlParameter("@MGOFILE", SqlDbType.VarChar)
DataParm(13) = New SqlParameter("@MGOFILL", SqlDbType.VarChar)
DataParm(14) = New SqlParameter("@MGOUNIT", SqlDbType.VarChar)
DataParm(15) = New SqlParameter("@MGOIDAT", SqlDbType.VarChar)
DataParm(16) = New SqlParameter("@MGODELF", SqlDbType.Char)
DataParm(0).Value = argAdd_lst(0)
DataParm(1).Value = argAdd_lst(1)
DataParm(2).Value = argAdd_lst(2)
DataParm(3).Value = argAdd_lst(3)
DataParm(4).Value = argAdd_lst(4)
DataParm(5).Value = argAdd_lst(5)
DataParm(6).Value = argAdd_lst(6)
.
.
.