Re: [.NET] 下命令之後的text更新
剛剛試過了~的確
不下第二個命令 TEXT就還是連的上DB
附上程式碼會比較清楚~
以新增為例:
If txt_cusname.Text = "" Then
MsgBox("請輸入客戶姓名!")
Else
Try
Dim connDbStr, selectCmd, selectcmd2 As String
connDbStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Documents and Settings\User\My Documents\Visual Studio
2005\Projects\eye_manage\eye_manage\0829.mdb;"
selectCmd = "INSERT INTO cus_bdata
(cus_name,occu,cell_phone,home_phone,fax,E_mail,addr,birth,remark) VALUES ('"
& (txt_cusname.Text) & "', '" & (txt_job.Text) & "','" & (txt_cellphone.Text)
& "','" & (txt_home.Text) & "','" & (txt_fax.Text) & "', '" &
(txt_email.Text) & "', '" & (txt_addr.Text) & "',#" & (mtxt_cusbir.Text) &
"#,'" & (txt_cusmeno.Text) & "')"
selectcmd2 = "select * from cus_bdata"
Dim conn As OleDbConnection = New OleDbConnection(connDbStr)
conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand(selectCmd, conn)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(selectcmd2,
conn)
Dim ds As DataSet = New DataSet
cmd.ExecuteNonQuery()
da.Fill(ds, "cus_bdata")
DataGridView1.DataSource = ds.Tables("cus_bdata")
da.Dispose()
conn.Close()
MsgBox("更新成功!")
Catch ex As Exception
MessageBox.Show(ex.Message, "例外資訊")
End Try
txt_cusid.Text = ""
txt_cusname.Text = ""
txt_job.Text = ""
txt_cellphone.Text = ""
txt_home.Text = ""
txt_fax.Text = ""
txt_email.Text = ""
txt_addr.Text = ""
mtxt_cusbir.Text = ""
txt_cusmeno.Text = ""
End If
有高手知道如何處理咩?
感激不盡了!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.179.102
討論串 (同標題文章)