[.NET] vb2005 + sql server 新增資料
使用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