nekooee
سه شنبه 27 تیر 1391, 12:03 عصر
سلام
دوستان مشکل کد زیر چیه که مقادیر رو در دیتابیس ذخیره نمیکنه؟ بیچارم کرد بسکه کد رو عوض کردم و کار نکرد
Imports System.Data.OleDb
Public Class GhabzForm : Inherits System.Windows.Forms.Form
Private Sub GhabzForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\tamirkar\beta\tamirkar\database.mdb;"
Dim conn As OleDbConnection = New OleDbConnection(ConnectionString)
Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO phones (PNAME, PAddress, PTEL) VALUES (?, ?, ?)", conn)
cmd.Parameters.Add("@PNAME", OleDbType.VarChar, 255).Value = PNAMETextBox.Text
cmd.Parameters.Add("@PAddress", OleDbType.VarChar, 255).Value = PAddressTextBox.Text
cmd.Parameters.Add("@PTEL", OleDbType.VarNumeric, 255).Value = PTELTextBox.Text
Try
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
Finally
conn.Close()
End Try
End Sub
End Class
دوستان مشکل کد زیر چیه که مقادیر رو در دیتابیس ذخیره نمیکنه؟ بیچارم کرد بسکه کد رو عوض کردم و کار نکرد
Imports System.Data.OleDb
Public Class GhabzForm : Inherits System.Windows.Forms.Form
Private Sub GhabzForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\tamirkar\beta\tamirkar\database.mdb;"
Dim conn As OleDbConnection = New OleDbConnection(ConnectionString)
Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO phones (PNAME, PAddress, PTEL) VALUES (?, ?, ?)", conn)
cmd.Parameters.Add("@PNAME", OleDbType.VarChar, 255).Value = PNAMETextBox.Text
cmd.Parameters.Add("@PAddress", OleDbType.VarChar, 255).Value = PAddressTextBox.Text
cmd.Parameters.Add("@PTEL", OleDbType.VarNumeric, 255).Value = PTELTextBox.Text
Try
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
Finally
conn.Close()
End Try
End Sub
End Class