查看: 1805|回复: 13
|
VB.NET 跟 Microsoft database 问题 紧急!!!
[复制链接]
|
|
我的database不懂做么当我一改code的时候。。。table里我用application insert的资料就不见了只剩下我用database insert的资料罢了。。。为什么会这样啊??谁能帮帮我~~~ |
|
|
|
|
|
|
|
发表于 3-11-2010 01:31 AM
|
显示全部楼层
回复 1# js_lee
不明白你的意识,请表达清楚点 |
|
|
|
|
|
|
|
发表于 3-11-2010 11:37 AM
|
显示全部楼层
我也看不懂 |
|
|
|
|
|
|
|
发表于 3-11-2010 11:46 AM
|
显示全部楼层
说得具体一点吧。。。。
我记得一些情况下,DEBUG MODE INSERT DATA 在 DATABASE 不会出现。 |
|
|
|
|
|
|
|
发表于 3-11-2010 11:55 AM
|
显示全部楼层
很抽象~
真个情况搬进来将吧~
或者直接把coding放进来 |
|
|
|
|
|
|
|
发表于 3-11-2010 06:26 PM
|
显示全部楼层
本帖最后由 宅男-兜着走 于 3-11-2010 06:32 PM 编辑
使用文件型资料库在 Debug 模式下会覆盖你bin文件夹内的资料库。
就酱
不相信我的话, 你Insert 了资料后, 关掉程式, 打开
c:\documents\Visual Studio 20xx\YourProjectName\debug\bin
也或者, 你在你Visual Studio内的 Solution Explorer 那里按 “Show All Files”
就会看到一个白色的文件夹写着 “bin”, 找出你资料库的文件后, 双击。 |
|
|
|
|
|
|
|
楼主 |
发表于 3-11-2010 08:28 PM
|
显示全部楼层
本帖最后由 js_lee 于 3-11-2010 08:36 PM 编辑
简单的说...一开始我做我database的table的资料时候只有username是admin跟password是123...之后我在vb.net里做了个insertform去insert新的资料...insert新资料是没问题...database的table都会有我insertform insert的资料...就算我关掉重开在insert过新资料还是没问题...可是当我去改或加code减code时再跑example我加多个MsgBox的code...我的database的table资料就只剩下admin跟123资料罢了...其他我用insertform的资料都没有了... |
|
|
|
|
|
|
|
楼主 |
发表于 3-11-2010 08:32 PM
|
显示全部楼层
回复 6# 宅男-兜着走
不是很看得懂勒...你讲的那个白色的bin我找得到...可是你要我看什么?? |
|
|
|
|
|
|
|
楼主 |
发表于 3-11-2010 08:34 PM
|
显示全部楼层
这是我insert form的code
Dim dataset As New DataSet
Dim password As Integer = 0
connection.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Members.mdf;Integrated Security=True;User Instance=True")
Command.CommandText = "SELECT * FROM [User] WHERE Username= '" & usernameTextBox.Text & "';"
connection.Open()
Command.Connection = connection
adaptor.SelectCommand = command
adaptor.Fill(dataset, "0")
'MsgBox(usernameTextBox.Text)
Dim count = dataset.Tables(0).Rows.Count
'MsgBox(dataset.Tables(0).Rows(0)(0).ToString)
If count >= 1 Then
MsgBox("Error!The username already use. Please try other.", MsgBoxStyle.Critical)
usernameTextBox.Text = String.Empty
connection.Close()
Else
insertCommand.Connection = connection
insertCommand.CommandText = "INSERT INTO [User] (Username, Password) VALUES ('" & usernameTextBox.Text & "', '" & password & "')"
insertCommand.ExecuteNonQuery()
MsgBox("Insert Succesful.", MsgBoxStyle.Information)
connection.Close()
usernameTextBox.Text = String.Empty
MsgBox("aaa")
SelectForm.Show()
Me.Close()
End If
其它没declare的我在module里declare了 |
|
|
|
|
|
|
|
发表于 3-11-2010 09:33 PM
|
显示全部楼层
本帖最后由 宅男-兜着走 于 3-11-2010 09:35 PM 编辑
这是我insert form的code
Dim dataset As New DataSet
Dim password As Integer = 0
...
js_lee 发表于 3-11-2010 08:34 PM
- Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Members.mdf;Integrated Security=True;User Instance=True")
复制代码
当你的程式 Debug 后, Insert 了资料, 然后关掉。
照我之前说的,看到白色的bin 后, 跟着以下顺序去打开folder, 就会看到你的 members.mdf
双击白色的members.mdf ,
bin -> Debug -> (双击)Members.mdf
然后server explorer就会看到 members.mdf1 , 打开后, Right Click 你的Table, 然后 Show Table data。
你Insert 的资料在里面。
我不是要表达什么, 因为你insert 资料的时候, 是insert 在你的 bin/Debug/Members.mdf 里面~
Winform 开发,都会覆盖掉你的资料库的,除非你有backup。 |
|
|
|
|
|
|
|
发表于 3-11-2010 09:47 PM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 7-11-2010 05:46 PM
|
显示全部楼层
回复 10# 宅男-兜着走
这么说的话。。。如果我把我的database不要存在debug呢?这样的情况还会出现吗?? |
|
|
|
|
|
|
|
楼主 |
发表于 12-11-2010 09:09 PM
|
显示全部楼层
回复 11# 宅男-兜着走
我知道问题在哪里了,谢谢你了宅男。。。那个sql helper我会下载来看看的。。。多谢帮忙^^ |
|
|
|
|
|
|
|
发表于 15-11-2010 12:40 AM
|
显示全部楼层
|
|
|
|
|
|
| |
本周最热论坛帖子
|