简单问题(在数据库中新增数据)

pichu 2003-04-22 09:47:10
我想在数据库中新增一笔数据, 最简单的方法是如何做! 望指教!
Ps 我是用vb.net 写的
...全文
20 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yjmking 2003-04-23
  • 打赏
  • 举报
回复
还是insert into简单,速度又快
SirVBnet 2003-04-23
  • 打赏
  • 举报
回复
Dim anyrow As DataRow = DS_stuname.Tables("资料表名").NewRow
anyrow.Item("stuname") = TextBox1.Text
anyrow.Item("tel_no") = TextBox2.Text
DS_stuname.Tables("资料表名").Rows.Add(anyrow)

Dim objDataSetChanges As DS_stuname= New DS_stuname()
objDataSetChanges = CType(DS_stuname.GetChanges,YourType )
If (Not (objDataSetChanges) Is Nothing) Then
Try
Me.UpdateDataSource(objDataSetChanges)
Adapter_stuname.Update(DS_stuname)
DS_stuname.AcceptChanges()
Catch eUpdate As System.Exception
Throw eUpdate
End Try
End If
New_bug 2003-04-23
  • 打赏
  • 举报
回复
up
flers 2003-04-23
  • 打赏
  • 举报
回复
adapter.insertcommand=new sqlcommand("Insert into table1() Values()")
adapter.update(ds_stuname)
pichu 2003-04-23
  • 打赏
  • 举报
回复
看完MSDN之后我写了下面源码. 但仍未能新增数据

Dim anyrow As DataRow = DS_stuname.Tables("资料表名").NewRow
anyrow.Item("stuname") = TextBox1.Text
anyrow.Item("tel_no") = TextBox2.Text
DS_stuname.Tables("资料表名").Rows.Add(anyrow)
DS_stuname.AcceptChanges()
Adapter_stuname.Update(DS_stuname)

*注:数据表"数据表名"其中只有两 一栏名为"stuname"另一栏名为"tel_no"

希望各位指点!!
pichu 2003-04-23
  • 打赏
  • 举报
回复
谢谢各位, 问题己解决!!
vikingleo 2003-04-23
  • 打赏
  • 举报
回复
建议用SQL语句吧!

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧