[.NET] vb2005 + sql server 新增資料

看板Visual_Basic作者 ( 偶恨vb)時間17年前 (2008/06/09 18:21), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
使用vb2005 express 連結 sqlserver2005 express 做一新增資料的按鈕 _________________________ Private Sub btnNew_Click 前略 Dim strSQL As String strSQL = "Insert into tbOder(OrderNO,ODate,OcustomerNo,OProduct, ONeed,OQ,Priceper,PriceTotal,PreOKdate,PS ) Values (" & cm & ")" Dim SQLcomm As New SqlClient.SqlCommand(strSQL, Connection) Dim Rec As Integer Try Rec = SQLcomm.ExecuteNonQuery() MsgBox("新增" & Rec & "筆資料成功!") Catch ex As Exception MsgBox("新增失敗!" & ex.ToString) End Try Connection.Close() end sub ______________ 還有另一表單 含有datagridview 可直接瀏覽 資料表tbOder 在新增資料後 會show "新增1筆資料成功!" 去瀏覽datagridview 的確會出現新的資料 但一按"停止偵錯"的正方形 回去看資料庫裡的資料= =確沒有改變 請問這又素 什摸問題=__=a ? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.168.196.87 ※ 編輯: qayqay 來自: 218.168.196.87 (06/09 18:22)

06/09 20:07, , 1F
剛剛封裝後 就可以囉! (自問自答 =_=|||)
06/09 20:07, 1F
文章代碼(AID): #18JGGGMd (Visual_Basic)