mes
جمعه 28 فروردین 1383, 14:57 عصر
سلام
عزیزان ما میخام یه رکورد به فایل بانک اطلاعاتیم اضافه کنم به این صورت
Imports System.Data
'Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents t2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents t3 As System.Web.UI.WebControls.TextBox
Protected WithEvents t4 As System.Web.UI.WebControls.TextBox
Protected WithEvents t5 As System.Web.UI.WebControls.TextBox
Protected WithEvents t6 As System.Web.UI.WebControls.TextBox
Protected WithEvents t1 As System.Web.UI.WebControls.TextBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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 con As OleDbConnection
'Dim cmd As OleDbCommand
Dim da As OleDbDataAdapter
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
con = New OleDbConnection("provider=microsoft.jet.oledb.4.0;" & "data source=/inetpub/wwwroot/amalak/amlak.mdb")
con.Open()
'cmd = New OleDbCommand("select * from t2", con)
da = New OleDbDataAdapter("select * from t1", con)
da.Fill(ds, "t1")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newrow = ds.Tables("t1").NewRow()
newrow("user") = Val(t1.Text)
newrow("pass") = Val(t2.Text)
newrow("fname") = Val(t3.Text)
newrow("lname") = Val(t4.Text)
newrow("ph") = Val(t5.Text)
newrow("h") = Val(t6.Text)
ds.Tables("t1").Rows.Add(newrow)
cb = New OleDbCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand
da.Update(ds, "t1")
con.Close()
End Sub
End Class
اا تو این قسمت اشکال میده
da.Update(ds, "t1")
یا علی
عزیزان ما میخام یه رکورد به فایل بانک اطلاعاتیم اضافه کنم به این صورت
Imports System.Data
'Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents t2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents t3 As System.Web.UI.WebControls.TextBox
Protected WithEvents t4 As System.Web.UI.WebControls.TextBox
Protected WithEvents t5 As System.Web.UI.WebControls.TextBox
Protected WithEvents t6 As System.Web.UI.WebControls.TextBox
Protected WithEvents t1 As System.Web.UI.WebControls.TextBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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 con As OleDbConnection
'Dim cmd As OleDbCommand
Dim da As OleDbDataAdapter
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
con = New OleDbConnection("provider=microsoft.jet.oledb.4.0;" & "data source=/inetpub/wwwroot/amalak/amlak.mdb")
con.Open()
'cmd = New OleDbCommand("select * from t2", con)
da = New OleDbDataAdapter("select * from t1", con)
da.Fill(ds, "t1")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newrow = ds.Tables("t1").NewRow()
newrow("user") = Val(t1.Text)
newrow("pass") = Val(t2.Text)
newrow("fname") = Val(t3.Text)
newrow("lname") = Val(t4.Text)
newrow("ph") = Val(t5.Text)
newrow("h") = Val(t6.Text)
ds.Tables("t1").Rows.Add(newrow)
cb = New OleDbCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand
da.Update(ds, "t1")
con.Close()
End Sub
End Class
اا تو این قسمت اشکال میده
da.Update(ds, "t1")
یا علی