[.NET] vb2005 連結 資料庫 的 問題

看板Visual_Basic作者 (nenene)時間14年前 (2009/11/28 19:40), 編輯推噓2(206)
留言8則, 4人參與, 最新討論串1/1
請輸入專案類型(網站專案或者應用程式專案):VB2005 Express 剛學vb不是很久,還有很多觀念不懂.. 是這樣的 小弟我 為了用VB 2005連上資料庫 花了3天的時間 借了4本書 ... 我不知道是不是環境上的問題 想問一些比較基本的問題 本身是用 microsoft SQL server 2005 的資料庫 我看了許多書 是用控制項 Bindingsource 來建立 dataset 可是我寫入資料到 Dataset 最後都回不到原本架好的資料庫... 我不知道是我哪裡設定錯誤了呢 ------------------------------------------------------------ Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.membertableadapter.Fill(Me.memberDataset.member) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addBtn.Click Try memberBindingSource.Addnew() Catch ex As Exception MsgBox("已經有人使用此帳號") End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try memberBindingSource.endedit() membertableadapter.update(Me.memberdataset.member) MsgBox("恭喜成為會員") Catch ex As Exception MsgBox("加入失敗!!") End Try End Sub End Class ----------------------------------------------------------------- 這是用來測試將寫入的資料寫回資料庫的簡易程式 可以成功run出來 但是 最後都不會真正寫回資料庫 這是依照參考書範例上寫出來的 請厲害的高手們幫我解惑一下吧 感激不盡!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.135.113.149

11/29 00:29, , 1F
membertableadapter <== find definition and seek real
11/29 00:29, 1F

11/29 00:30, , 2F
connection to which Database
11/29 00:30, 2F

11/29 03:15, , 3F
不懂...可以說詳細一點嗎...謝謝~
11/29 03:15, 3F

11/29 23:29, , 4F
資料庫沒連對
11/29 23:29, 4F

12/05 22:45, , 5F
沒看到連線字串阿~基本要透過connection物件連線
12/05 22:45, 5F

12/05 22:45, , 6F
再用command物件去執行SQL在看要用Datareader或是
12/05 22:45, 6F

12/05 22:47, , 7F
看你是用DataAdapter物件因此需要用到dataset物件
12/05 22:47, 7F

12/09 10:05, , 8F
..
12/09 10:05, 8F
文章代碼(AID): #1B4Gn9Nt (Visual_Basic)