reza_vb64
شنبه 12 بهمن 1387, 11:50 صبح
وقتی قطعه برنامه زیر را اجرا می کنم خطای زیر داده می شود و
da.Update(ds, "Tvisit") پر رنگ می شود .
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Syntax error in INSERT INTO statement.
imports System.Data
Imports System.Data.OleDb
Public Class Form5
Dim connectionstring As String = "provider=microsoft.jet.oledb.4.0;data source=""f:\hospital.mdb"""
Dim con1 As New OleDb.OleDbConnection(connectionstring)
Dim cmd As New OleDb.OleDbCommand("", con1)
Dim da1 As New OleDb.OleDbDataAdapter("", connectionstring)
Dim dt As New DataTable
Dim ds As New DataSet
Dim strsql As String
Dim strcon As String = "provider=microsoft.jet.oledb.4.0;data source=f:\hospital.mdb"
Dim da As OleDbDataAdapter
Dim con As OleDbConnection
Dim newmode As Boolean
Dim newrow As DataRow
Dim cb As OleDbCommandBuilder
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Reza.t_time' table. You can move, or remove it, as needed.
'TODO: This line of code loads data into the 'Reza.Tdoctime' table. You can move, or remove it, as needed.
Me.TdoctimeTableAdapter.Fill(Me.Reza.Tdoctime)
'TODO: This line of code loads data into the 'Reza.Tdoctor' table. You can move, or remove it, as needed.
Me.TdoctorTableAdapter.Fill(Me.Reza.Tdoctor)
newmode = False
strsql = "select doc_id,id_patient,date,time,stetment from Tvisit"
con = New OleDbConnection(strcon)
con.Open()
da = New OleDbDataAdapter(strsql, con)
da.Fill(ds, "Tvisit")
con.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
con1.Open()
cmd.CommandText = "select (Max(ID_patient)) from Tpatient "
Label6.Text = cmd.ExecuteScalar
con1.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newrow = ds.Tables("Tvisit").NewRow
newmode = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If newmode = True Then
newrow("doc_id") = Label7.Text
newrow("date") = ComboBox2.Text
newrow("id_patient") = Label6.Text
newrow("time") = TextBox2.Text
newrow("stetment") = TextBox1.Text
ds.Tables("Tvisit").Rows.Add(newrow)
cb = New OleDbCommandBuilder(da)
da = cb.DataAdapter
da.Update(ds, "Tvisit")
con.Close()
Else
cb = New OleDbCommandBuilder(da)
da.Update(ds, "Tvisit")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim s As Char
If ds.HasChanges Then
s = InputBox("y")
If s = "y" Then
cb = New OleDbCommandBuilder(da)
da.Update(ds, "Tvisit")
con.Close()
Else
Form6.Show()
End If
Else
Form6.Show()
End If
End Sub
End Class
da.Update(ds, "Tvisit") پر رنگ می شود .
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Syntax error in INSERT INTO statement.
imports System.Data
Imports System.Data.OleDb
Public Class Form5
Dim connectionstring As String = "provider=microsoft.jet.oledb.4.0;data source=""f:\hospital.mdb"""
Dim con1 As New OleDb.OleDbConnection(connectionstring)
Dim cmd As New OleDb.OleDbCommand("", con1)
Dim da1 As New OleDb.OleDbDataAdapter("", connectionstring)
Dim dt As New DataTable
Dim ds As New DataSet
Dim strsql As String
Dim strcon As String = "provider=microsoft.jet.oledb.4.0;data source=f:\hospital.mdb"
Dim da As OleDbDataAdapter
Dim con As OleDbConnection
Dim newmode As Boolean
Dim newrow As DataRow
Dim cb As OleDbCommandBuilder
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Reza.t_time' table. You can move, or remove it, as needed.
'TODO: This line of code loads data into the 'Reza.Tdoctime' table. You can move, or remove it, as needed.
Me.TdoctimeTableAdapter.Fill(Me.Reza.Tdoctime)
'TODO: This line of code loads data into the 'Reza.Tdoctor' table. You can move, or remove it, as needed.
Me.TdoctorTableAdapter.Fill(Me.Reza.Tdoctor)
newmode = False
strsql = "select doc_id,id_patient,date,time,stetment from Tvisit"
con = New OleDbConnection(strcon)
con.Open()
da = New OleDbDataAdapter(strsql, con)
da.Fill(ds, "Tvisit")
con.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
con1.Open()
cmd.CommandText = "select (Max(ID_patient)) from Tpatient "
Label6.Text = cmd.ExecuteScalar
con1.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newrow = ds.Tables("Tvisit").NewRow
newmode = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If newmode = True Then
newrow("doc_id") = Label7.Text
newrow("date") = ComboBox2.Text
newrow("id_patient") = Label6.Text
newrow("time") = TextBox2.Text
newrow("stetment") = TextBox1.Text
ds.Tables("Tvisit").Rows.Add(newrow)
cb = New OleDbCommandBuilder(da)
da = cb.DataAdapter
da.Update(ds, "Tvisit")
con.Close()
Else
cb = New OleDbCommandBuilder(da)
da.Update(ds, "Tvisit")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim s As Char
If ds.HasChanges Then
s = InputBox("y")
If s = "y" Then
cb = New OleDbCommandBuilder(da)
da.Update(ds, "Tvisit")
con.Close()
Else
Form6.Show()
End If
Else
Form6.Show()
End If
End Sub
End Class