作者qayqay ( 偶恨vb)
看板Visual_Basic
標題[.NET] vb2005 express + sql server 2005 express 新增資料問題
時間Mon Jun 9 18:21:03 2008
使用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)
1F:→ qayqay:剛剛封裝後 就可以囉! (自問自答 =_=|||) 06/09 20:07