用的VB,在书上看,可以用DataRow来做,但是我想直接用SQL进行,可以吗?哪种比较好?
我用SQL这样写的,
dim upcommand as New SqlCommand(Insert into infom(No,name,age) Values("&no&","&name&","&age&")
upcommand.Connection.Open()
upcommand.ExecuteNonQuery()
总说编译错误呀,怎么回事?语句应该怎么写?
小妹谢过了~
我用SQL这样写的,
dim upcommand as New SqlCommand(Insert into infom(No,name,age) Values("&no&","&name&","&age&")
upcommand.Connection.Open()
upcommand.ExecuteNonQuery()
总说编译错误呀,怎么回事?语句应该怎么写?
小妹谢过了~
解决方案 »
- visual studio2008设计器问题
- [求助]大家帮忙看下这个错误是怎么回事?
- 求一vs2003+access开发的论坛。
- 怎样在点击确定之后才开始跳转网页?
- 用vs.net怎样将连接数据库的代码放在一个地方每页能够调用?
- 把一个网页的变量的值传给另一个网页后,如何赋给这个网页的控件?
- 我想学习微软的petshop例程,但是苦于没有vb的版本
- Treeview的问题
- 字符串连接问题"+DayMY.ToString ()+"+"+MaxPrjIDin.ToString()+",其中DayMY,MaxPrjIDin都是数字,我想把他们变成字符连接起来,可是总
- DateTime类型使用,求助
- 50分跪求Response.Write()从codebehind写出vml在客户端显示一个圆!!!用C#
- 为什么这样的代码执行错误?
dim name as string = "aaaaaa"
dim age as string = "18"
dim sql as string = "Insert into infom(No,name,age) Values('" & no & "','" & name & "','" & age & "'"
dim upcommand as New SqlCommand(sql)
'......
string strsql = "Insert into infom(No,name,age) Values ('"&no&"','"&name&"','"&age&"')"
dim upcommand as New SqlCommand(strsql)
运算符“&”不是为类型“String”和“System.Web.UI.WebControls.TextBox”定义的
怎么办??
upcommand.Connection.Open()
upcommand.ExecuteNonQuery()
怎么回事?我晕呀……
代码如下:
dim upConnect as string
upConnect="database=myexp;server=localhost;uid=sa;pwd=;"
dim upConnection as New SqlConnection(upConnect)
dim strsql as string
strsql="SELECT * FROM infom"
dim upcommand as New SqlCommand(strsql,upConnection)
dim upDataSet as New DataSet()
dim upAdapter as SqlDataAdapter
upAdapter.Fill(upDataSet,"infom")
dim upTable as DataTable
upTable=upDataSet.Tables("infom")
dim upNewRow as DataRow
upNewRow=upTable.NewRow()
upNewRow("No")=6
upNewRow("name")="Innsbruck"
upNewRow("age")=32
upTable.Rows.Add(upNewRow)
dim upBuilder as SqlCommandBuilder
upBuilder= New SqlCommandBuilder(upAdapter)
upAdapter.InsertCommand = upBuilder.GetInsertCommand()
upAdapter.Update(upDataSet,"infom")
upcommand.Connection.Open()
upcommand.ExecuteNonQuery()
dim upcommand as New SqlCommand(strsql)
c#裡應該改&為+
现在提示的错误是“ 在调用“Fill”前,SelectCommand 属性尚未初始化。”
怎么回事?