S
slinky
I'm working on a problem with a form with 6 textboxes and a submit
button for adding data to an Access database.I changed a few things
and got it down to 1 error!. I have a Sub
Page_Load and a Sub btnAdd:
(It still doesn't like the 'SourceVersion' in the Sub Page_Load).
Also
I viewed the .aspx in the browser and got an error which I posted
complete at the bottom of this post). Thanks for any clues... I'm
almost there!!
Imports System.Data
Imports System.Data.OleDb
Public Class Default5
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnn As OleDbConnection = _
New OleDbConnection("Data Source=(local);" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
If IsPostBack Then
Dim cmdSelect As OleDbCommand = _
cnn.CreateCommand()
cmdSelect.CommandType = CommandType.Text
cmdSelect.CommandText = _
"SELECT (Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) FROM Assets"
Dim cmdInsert As OleDbCommand = _
cnn.CreateCommand()
cmdInsert.CommandType = CommandType.Text
cmdInsert.CommandText = _
"INSERT INTO Assets " & _
"(Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) " & _
"VALUES(@Asset_Number, @Description, @Serial_Number, @Mfg,
@AssetType,
@RDCnumber"
cmdInsert.Parameters.Add("@txtAsset_Number",
OleDbType.Double, 12, "Asset_Number")
cmdInsert.Parameters.Add("@txtDescription",
OleDbType.WChar, 40, "Description")
cmdInsert.Parameters.Add("@txtSerial_Number",
OleDbType.WChar, 30, "Serial_Number")
cmdInsert.Parameters.Add("@txtMfg", OleDbType.WChar, 30,
"Mfg")
cmdInsert.Parameters.Add("@txtAssetType",
OleDbType.WChar,
30, "AssetType")
cmdInsert.Parameters.Add("@txtRDCNumber",
OleDbType.WChar,
30, "RDCnumber")
Dim SourceVersion As DataRowVersion
SourceVersion = DataRowVersion.Original
da.SelectCommand = cmdSelect
da.InsertCommand = cmdInsert
da.Fill(ds, "Assets")
End If
End Sub
Private Sub btnAdd_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd.Click
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
Dim dr As DataRow = ds.Tables("Assets").NewRow()
dr(0) = txtAsset_Number.Text
dr(1) = txtDescription.Text
dr(2) = txtSerial_Number.Text
dr(3) = txtMfg.Text
dr(4) = txtAssetType.Text
dr(5) = txtRDCnumber.Text
ds.Tables("Assets").Rows.Add(dr)
da.Update(ds, "Assets")
End Sub
End Class
__________________________
Server Error in '/' Application.
--------------------------------------------------------------------------------
An OLE DB Provider was not specified in the ConnectionString. An
example would be, 'Provider=SQLOLEDB;'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An OLE DB Provider was
not specified in the ConnectionString. An example would be,
'Provider=SQLOLEDB;'.
Source Error:
Line 5: Private Sub Page_Load(ByVal sender As System.Object, _
Line 6: ByVal e As System.EventArgs) Handles MyBase.Load
Line 7: Dim cnn As OleDbConnection = _
Line 8: New OleDbConnection("Data Source=(local);" & _
Line 9: "Initial Catalog=Assets;Integrated Security=SSPI")
Source File: E:\kunden\homepages\26\d190091667\Default5.aspx.vb
Line: 7
Stack Trace:
[ArgumentException: An OLE DB Provider was not specified in the
ConnectionString. An example would be, 'Provider=SQLOLEDB;'.]
System.Data.OleDb.OleDbConnectionString.ValidateProvider(String
progid) +1044303
System.Data.OleDb.OleDbConnectionString.ValidateConnectionString(String
connectionString) +221
System.Data.OleDb.OleDbConnectionString..ctor(String
connectionString, Boolean validate) +271
System.Data.OleDb.OleDbConnectionFactory.CreateConnectionOptions(String
connectionString, DbConnectionOptions previous) +36
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String
connectionString, DbConnectionPoolGroupOptions poolOptions,
DbConnectionOptions& userConnectionOptions) +125
System.Data.OleDb.OleDbConnection.ConnectionString_Set(String
value) +56
System.Data.OleDb.OleDbConnection.set_ConnectionString(String
value) +4
System.Data.OleDb.OleDbConnection..ctor(String connectionString)
+21
Default5.Page_Load(Object sender, EventArgs e) in E:\kunden
\homepages\26\d190091667\Default5.aspx.vb:7
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061
button for adding data to an Access database.I changed a few things
and got it down to 1 error!. I have a Sub
Page_Load and a Sub btnAdd:
(It still doesn't like the 'SourceVersion' in the Sub Page_Load).
Also
I viewed the .aspx in the browser and got an error which I posted
complete at the bottom of this post). Thanks for any clues... I'm
almost there!!
Imports System.Data
Imports System.Data.OleDb
Public Class Default5
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnn As OleDbConnection = _
New OleDbConnection("Data Source=(local);" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
If IsPostBack Then
Dim cmdSelect As OleDbCommand = _
cnn.CreateCommand()
cmdSelect.CommandType = CommandType.Text
cmdSelect.CommandText = _
"SELECT (Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) FROM Assets"
Dim cmdInsert As OleDbCommand = _
cnn.CreateCommand()
cmdInsert.CommandType = CommandType.Text
cmdInsert.CommandText = _
"INSERT INTO Assets " & _
"(Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) " & _
"VALUES(@Asset_Number, @Description, @Serial_Number, @Mfg,
@AssetType,
@RDCnumber"
cmdInsert.Parameters.Add("@txtAsset_Number",
OleDbType.Double, 12, "Asset_Number")
cmdInsert.Parameters.Add("@txtDescription",
OleDbType.WChar, 40, "Description")
cmdInsert.Parameters.Add("@txtSerial_Number",
OleDbType.WChar, 30, "Serial_Number")
cmdInsert.Parameters.Add("@txtMfg", OleDbType.WChar, 30,
"Mfg")
cmdInsert.Parameters.Add("@txtAssetType",
OleDbType.WChar,
30, "AssetType")
cmdInsert.Parameters.Add("@txtRDCNumber",
OleDbType.WChar,
30, "RDCnumber")
Dim SourceVersion As DataRowVersion
SourceVersion = DataRowVersion.Original
da.SelectCommand = cmdSelect
da.InsertCommand = cmdInsert
da.Fill(ds, "Assets")
End If
End Sub
Private Sub btnAdd_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd.Click
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
Dim dr As DataRow = ds.Tables("Assets").NewRow()
dr(0) = txtAsset_Number.Text
dr(1) = txtDescription.Text
dr(2) = txtSerial_Number.Text
dr(3) = txtMfg.Text
dr(4) = txtAssetType.Text
dr(5) = txtRDCnumber.Text
ds.Tables("Assets").Rows.Add(dr)
da.Update(ds, "Assets")
End Sub
End Class
__________________________
Server Error in '/' Application.
--------------------------------------------------------------------------------
An OLE DB Provider was not specified in the ConnectionString. An
example would be, 'Provider=SQLOLEDB;'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An OLE DB Provider was
not specified in the ConnectionString. An example would be,
'Provider=SQLOLEDB;'.
Source Error:
Line 5: Private Sub Page_Load(ByVal sender As System.Object, _
Line 6: ByVal e As System.EventArgs) Handles MyBase.Load
Line 7: Dim cnn As OleDbConnection = _
Line 8: New OleDbConnection("Data Source=(local);" & _
Line 9: "Initial Catalog=Assets;Integrated Security=SSPI")
Source File: E:\kunden\homepages\26\d190091667\Default5.aspx.vb
Line: 7
Stack Trace:
[ArgumentException: An OLE DB Provider was not specified in the
ConnectionString. An example would be, 'Provider=SQLOLEDB;'.]
System.Data.OleDb.OleDbConnectionString.ValidateProvider(String
progid) +1044303
System.Data.OleDb.OleDbConnectionString.ValidateConnectionString(String
connectionString) +221
System.Data.OleDb.OleDbConnectionString..ctor(String
connectionString, Boolean validate) +271
System.Data.OleDb.OleDbConnectionFactory.CreateConnectionOptions(String
connectionString, DbConnectionOptions previous) +36
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String
connectionString, DbConnectionPoolGroupOptions poolOptions,
DbConnectionOptions& userConnectionOptions) +125
System.Data.OleDb.OleDbConnection.ConnectionString_Set(String
value) +56
System.Data.OleDb.OleDbConnection.set_ConnectionString(String
value) +4
System.Data.OleDb.OleDbConnection..ctor(String connectionString)
+21
Default5.Page_Load(Object sender, EventArgs e) in E:\kunden
\homepages\26\d190091667\Default5.aspx.vb:7
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061