dr_marteen
دوشنبه 28 آذر 1384, 00:56 صبح
سطری که خطا تولید می کند را با نوع خطا مشخص کرده ام . لطفا راهنمایی کنید
برنامه اطلاعاتی را گرفته و در فایل اکسس قرار می دهد
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents stno As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents course As System.Web.UI.WebControls.TextBox
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents ave As System.Web.UI.WebControls.TextBox
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents numunit As System.Web.UI.WebControls.TextBox
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents firstname As System.Web.UI.WebControls.TextBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim ds As New DataSet
Dim strsql As String
Dim strcon As String
Dim da As OleDbDataAdapter
Dim con As OleDbConnection
Dim newrow As DataRow
Dim cb As OleDbCommandBuilder
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strcon = "provider = microsoft.Jet.OLEDB.4.0.;" & "data source=C:\Inetpub\wwwroot\db\student.mdb"
strsql = "select * from sttable"
con = New OleDbConnection(strcon)
con.Open()
da = New OleDbDataAdapter(strsql, con)
da.Fill(ds, "sttable")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newrow = ds.Tables("sttable").NewRow()
newrow("stno") = stno.Text
newrow("name") = firstname.Text
newrow("course") = course.Text
newrow("ave") = ave.Text
newrow("numunit") = numunit.Text
ds.Tables("sttable").Rows.Add(newrow)
cb = New OleDbCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand()
ERROR => Operation must use an updatable query <== da.Update(ds, "sttable")
con.Close()
stno.Text = ""
firstname.Text = ""
course.Text = ""
ave.Text = ""
numunit.Text = ""
End Sub
End Class
5
برنامه اطلاعاتی را گرفته و در فایل اکسس قرار می دهد
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents stno As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents course As System.Web.UI.WebControls.TextBox
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents ave As System.Web.UI.WebControls.TextBox
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents numunit As System.Web.UI.WebControls.TextBox
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents firstname As System.Web.UI.WebControls.TextBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim ds As New DataSet
Dim strsql As String
Dim strcon As String
Dim da As OleDbDataAdapter
Dim con As OleDbConnection
Dim newrow As DataRow
Dim cb As OleDbCommandBuilder
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strcon = "provider = microsoft.Jet.OLEDB.4.0.;" & "data source=C:\Inetpub\wwwroot\db\student.mdb"
strsql = "select * from sttable"
con = New OleDbConnection(strcon)
con.Open()
da = New OleDbDataAdapter(strsql, con)
da.Fill(ds, "sttable")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newrow = ds.Tables("sttable").NewRow()
newrow("stno") = stno.Text
newrow("name") = firstname.Text
newrow("course") = course.Text
newrow("ave") = ave.Text
newrow("numunit") = numunit.Text
ds.Tables("sttable").Rows.Add(newrow)
cb = New OleDbCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand()
ERROR => Operation must use an updatable query <== da.Update(ds, "sttable")
con.Close()
stno.Text = ""
firstname.Text = ""
course.Text = ""
ave.Text = ""
numunit.Text = ""
End Sub
End Class
5