佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1273|回复: 4

vb.net 数据库求救

[复制链接]
发表于 18-6-2010 12:22 AM | 显示全部楼层 |阅读模式
各位,我的程序打算能让user 输入data进入database,可是现在的问题是程序走完时,跳出窗口说输入成功,可是在数据库里找不到资料。。。我试过很多方法,结果还是一样。。。希望会的人能帮帮我...以下就是我的代码

  1.       Dim adapter As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM Inventory ", CtnLogin)
  2.         Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)
  3.         Dim dataset As DataSet = New DataSet

  4.         adapter.Fill(dataset, "Inventory")
  5.         Dim datatable As DataTable = dataset.Tables("Inventory")

  6.         Dim newRow As DataRow = datatable.NewRow()
  7.         newRow("InventoryNo") = txtInventoryNo.Text
  8.         newRow("StockItemNo") = 1
  9.         newRow("InventoryPrice") = txtPrice.Text
  10.         newRow("InventoryQuantity") = txtInventoryQuantity.Text
  11.         newRow("InventoryMeasurement") = txtMeasurement.Text
  12.         newRow("InventoryProcureMethod") = txtMethod.Text
  13.         newRow("InventoryProcureDate") = Convert.ToDateTime(DateTimePicker1.Value)
  14.         newRow("InventoryExpiryDate") = Convert.ToDateTime(DateTimePicker2.Value)
  15.         newRow("UserNo") = "U001"

  16.         datatable.Rows.Add(newRow)
  17.         adapter.Update(dataset, "Inventory")
  18.         MessageBox.Show("successfully inserted into database", "success info", MessageBoxButtons.OK, MessageBoxIcon.Information)
  19.         CtnLogin.Close()
复制代码
回复

使用道具 举报


ADVERTISEMENT

发表于 21-6-2010 02:26 PM | 显示全部楼层
不好意思哦!有个小小的问题问你!!你可以拿DATA出来吗?
SELECT * FROM Inventory???
回复

使用道具 举报

 楼主| 发表于 21-6-2010 06:54 PM | 显示全部楼层
回复 2# tatt2

可以拿啊,根据那个"SELECT * FROM Inventory" ,在用datareader 来execute
回复

使用道具 举报

发表于 12-7-2010 11:06 AM | 显示全部楼层
参考这里的例子,会不会是漏了builder.GetUpdateCommand()

http://msdn.microsoft.com/en-us/ ... adapter.update.aspx
回复

使用道具 举报

 楼主| 发表于 17-7-2010 06:24 PM | 显示全部楼层
谢谢大家尝试帮忙,我已经找到原因了,原来是能走的,只是debugger问题
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 21-5-2024 06:26 PM , Processed in 0.053880 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表