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.Ole Db
Public Class Default5
Inherits System.Web.UI.P age
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) 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 OleDbDataAdapte r = New OleDbDataAdapte r()
If IsPostBack Then
Dim cmdSelect As OleDbCommand = _
cnn.CreateComma nd()
cmdSelect.Comma ndType = CommandType.Tex t
cmdSelect.Comma ndText = _
"SELECT (Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) FROM Assets"
Dim cmdInsert As OleDbCommand = _
cnn.CreateComma nd()
cmdInsert.Comma ndType = CommandType.Tex t
cmdInsert.Comma ndText = _
"INSERT INTO Assets " & _
"(Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) " & _
"VALUES(@Asset_ Number, @Description, @Serial_Number, @Mfg,
@AssetType,
@RDCnumber"
cmdInsert.Param eters.Add("@txt Asset_Number",
OleDbType.Doubl e, 12, "Asset_Numb er")
cmdInsert.Param eters.Add("@txt Description",
OleDbType.WChar , 40, "Descriptio n")
cmdInsert.Param eters.Add("@txt Serial_Number",
OleDbType.WChar , 30, "Serial_Number" )
cmdInsert.Param eters.Add("@txt Mfg", OleDbType.WChar , 30,
"Mfg")
cmdInsert.Param eters.Add("@txt AssetType",
OleDbType.WChar ,
30, "AssetType" )
cmdInsert.Param eters.Add("@txt RDCNumber",
OleDbType.WChar ,
30, "RDCnumber" )
Dim SourceVersion As DataRowVersion
SourceVersion = DataRowVersion. Original
da.SelectComman d = cmdSelect
da.InsertComman d = cmdInsert
da.Fill(ds, "Assets")
End If
End Sub
Private Sub btnAdd_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnAdd.Click
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapte r = New OleDbDataAdapte r()
Dim dr As DataRow = ds.Tables("Asse ts").NewRow()
dr(0) = txtAsset_Number .Text
dr(1) = txtDescription. Text
dr(2) = txtSerial_Numbe r.Text
dr(3) = txtMfg.Text
dr(4) = txtAssetType.Te xt
dr(5) = txtRDCnumber.Te xt
ds.Tables("Asse ts").Rows.Add(d r)
da.Update(ds, "Assets")
End Sub
End Class
_______________ ___________
Server Error in '/' Application.
---------------------------------------------------------------------------*-----
An OLE DB Provider was not specified in the ConnectionStrin g. An
example would be, 'Provider=SQLOL EDB;'.
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.Argument Exception: An OLE DB Provider was
not specified in the ConnectionStrin g. An example would be,
'Provider=SQLOL EDB;'.
Source Error:
Line 5: Private Sub Page_Load(ByVal sender As System.Object, _
Line 6: ByVal e As System.EventArg s) 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\homep ages\26\d190091 667\Default5.as px.vb
Line: 7
Stack Trace:
[ArgumentExcepti on: An OLE DB Provider was not specified in the
ConnectionStrin g. An example would be, 'Provider=SQLOL EDB;'.]
System.Data.Ole Db.OleDbConnect ionString.Valid ateProvider(Str ing
progid) +1044303
System.Data.Ole Db.OleDbConnect ionString.Valid ateConnectionSt ring(String
connectionStrin g) +221
System.Data.Ole Db.OleDbConnect ionString..ctor (String
connectionStrin g, Boolean validate) +271
System.Data.Ole Db.OleDbConnect ionFactory.Crea teConnectionOpt ions(String
connectionStrin g, DbConnectionOpt ions previous) +36
System.Data.Pro viderBase.DbCon nectionFactory. GetConnectionPo olGroup(String
connectionStrin g, DbConnectionPoo lGroupOptions poolOptions,
DbConnectionOpt ions& userConnectionO ptions) +125
System.Data.Ole Db.OleDbConnect ion.ConnectionS tring_Set(Strin g
value) +56
System.Data.Ole Db.OleDbConnect ion.set_Connect ionString(Strin g
value) +4
System.Data.Ole Db.OleDbConnect ion..ctor(Strin g connectionStrin g)
+21
Default5.Page_L oad(Object sender, EventArgs e) in E:\kunden
\homepages\26\d 190091667\Defau lt5.aspx.vb:7
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +99
System.Web.UI.C ontrol.LoadRecu rsive() +47
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
+1061