problem with .aspx.vb code

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
 
M

Mick Walker

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()
</snip>
Try

Dim cnn As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=(local);
Initial Catalog=Assets;Integrated Security=SSPI")

But this still wont work, because as far as I can see, you dont set the
path to the access file anywhere.
 
S

slinky

The database resides in the App_Data folder on my web provider's
server where my website objects reside. Do I need to put the path to
the URL? Thanks!
 
S

slinky

I changed the filepath and was able to get it to have no errors. But
when I ran my .aspx file I got the following error shown below my
code. Is the line "If IsPostBack" an issue? Thanks

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("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=(www.juggernautical.com\App_Data\Lowes.mdb);" & _
"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.
--------------------------------------------------------------------------------

Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.
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.Data.OleDb.OleDbException: Multiple-step OLE
DB operation generated errors. Check each OLE DB status value, if
available. No work was done.

Source Error:

Line 33: da.SelectCommand = cmdSelect
Line 34: da.InsertCommand = cmdInsert
Line 35: da.Fill(ds, "Assets")
Line 36: End If
Line 37: End Sub

Source File: E:\kunden\homepages\26\d190091667\Default5.aspx.vb
Line: 35

Stack Trace:

[OleDbException (0x80040e21): Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was
done.]

System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString
constr, DataSourceWrapper& datasrcWrapper) +209

System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString
constr, OleDbConnection connection) +118

System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningObject) +53

System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup) +27

System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +47

System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.OleDb.OleDbConnection.Open() +37
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) +83
Default5.Page_Load(Object sender, EventArgs e) in E:\kunden
\homepages\26\d190091667\Default5.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061
_______________________________
 
M

Mick Walker

slinky said:
I changed the filepath and was able to get it to have no errors. But
when I ran my .aspx file I got the following error shown below my
code. Is the line "If IsPostBack" an issue? Thanks
Use Server.MapPath or try the reletive path to the data file.
 
S

slinky

I've used Server.MapPath with reading an XML file into a dataset, but
am unsure how to phrase it for an Access Database. What I used for XML
was:

Using ds As New DataSet()
ds.ReadXml(Server.MapPath("blog.xml"))

So I'm unsure where to go from here. Here's what I'm coming up with
for the Connection for Page_Load:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=(Server.MapPath\App_Data\Lowes.mdb);" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

But do I need to do anything in the code for btnADD ?

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

I get no errors till I view in browser:
Source Error:

Line 33: da.SelectCommand = cmdSelect
Line 34: da.InsertCommand = cmdInsert
Line 35: da.Fill(ds, "Assets")
Line 36: End If
Line 37: End Sub

Line 35 is flagged in the browser as a problem.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

slinky said:
I've used Server.MapPath with reading an XML file into a dataset, but
am unsure how to phrase it for an Access Database. What I used for XML
was:

Using ds As New DataSet()
ds.ReadXml(Server.MapPath("blog.xml"))

So I'm unsure where to go from here. Here's what I'm coming up with
for the Connection for Page_Load:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=(Server.MapPath\App_Data\Lowes.mdb);" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

Server.MapPath is a method, not a folder. It turns a virtual path into a
physical path, so you supply it with a virtual path. A virtual path uses
/, not \.

Use this to get the physical path to the database file:

Server.MapPath("~/App_Data/Lowes.mdb")

Concatenate this into the connection string.
But do I need to do anything in the code for btnADD ?

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

You need to supply a database connection to the DataAdapter, otherwise
it doesn't know what to update.
I get no errors till I view in browser:
Source Error:

Line 33: da.SelectCommand = cmdSelect
Line 34: da.InsertCommand = cmdInsert
Line 35: da.Fill(ds, "Assets")
Line 36: End If
Line 37: End Sub

Line 35 is flagged in the browser as a problem.

What "problem"? You should include the error message.
 
S

slinky

I put this into my doce for the Page_Load and the btnAdd:

Dim cnn As OleDbConnection = _
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Server.MapPath(~/App_Data/Lowes.mdb));" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

I get no errors till I launch the browser and here's the complete
message.
I see below what I believe to be the physical path on my provider's
server:

E:\kunden\homepages\26\d190091667\Default5.aspx.vb

The actual URL to access my site to the page 'Default5.aspx (not the
module) is:
www.juggernautical.com/default5.aspx

______________________________________________________________________________________________

Server Error in '/' Application.
--------------------------------------------------------------------------------

Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.
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.Data.OleDb.OleDbException: Multiple-step OLE
DB operation generated errors. Check each OLE DB status value, if
available. No work was done.

Source Error:

Line 33: da.SelectCommand = cmdSelect
Line 34: da.InsertCommand = cmdInsert
Line 35: da.Fill(ds, "Assets") <<< This line
is in Red on screen
Line 36: End If
Line 37: End Sub

Source File: E:\kunden\homepages\26\d190091667\Default5.aspx.vb
Line: 35

Stack Trace:

[OleDbException (0x80040e21): Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was
done.]

System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString
constr, DataSourceWrapper& datasrcWrapper) +209

System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString
constr, OleDbConnection connection) +118

System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningObject) +53

System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup) +27

System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +47

System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.OleDb.OleDbConnection.Open() +37
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) +83
Default5.Page_Load(Object sender, EventArgs e) in E:\kunden
\homepages\26\d190091667\Default5.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

slinky said:
I put this into my doce for the Page_Load and the btnAdd:

Dim cnn As OleDbConnection = _
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Server.MapPath(~/App_Data/Lowes.mdb));" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

I get no errors till I launch the browser and here's the complete
message.
I see below what I believe to be the physical path on my provider's
server:

E:\kunden\homepages\26\d190091667\Default5.aspx.vb

The actual URL to access my site to the page 'Default5.aspx (not the
module) is:
www.juggernautical.com/default5.aspx

______________________________________________________________________________________________

Server Error in '/' Application.
--------------------------------------------------------------------------------

Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.
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.

Your select query is incorrect. If you have spaces in your field names,
you have to encode the names in brackets.

"SELECT ([Asset Number], Description, Serial_Number, Mfg, [Asset Type],
RDCnumber) FROM Assets"
 
S

slinky

OK I double checked and corrected any incident of misspelling or
brackets missing and corrected those. But still the browser brings up
this: (And I know nothing about
reading a stack)

Also, do I have this syntaxed correctly (ignore the '& _'s as they are
just from reformat on paste)?:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Server.MapPath(~/App_Data/Lowes.mdb));" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
___________________________________________________
Server Error in '/' Application.
--------------------------------------------------------------------------------

Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.
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.Data.OleDb.OleDbException: Multiple-step OLE
DB operation generated errors. Check each OLE DB status value, if
available. No work was done.

Source Error:


Line 33: da.SelectCommand = cmdSelect
Line 34: da.InsertCommand = cmdInsert
Line 35: da.Fill(ds, "Assets")
Line 36: End If
Line 37: End Sub


Source File: E:\kunden\homepages\26\d190091667\Default5.aspx.vb
Line: 35

Stack Trace:


[OleDbException (0x80040e21): Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was
done.]

System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString
constr, DataSourceWrapper& datasrcWrapper) +209

System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString
constr, OleDbConnection connection) +118

System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool,
DbConnection owningObject) +53

System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup) +27

System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +47

System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.OleDb.OleDbConnection.Open() +37
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) +83
Default5.Page_Load(Object sender, EventArgs e) in E:\kunden
\homepages\26\d190091667\Default5.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061


Your select query is incorrect. If you have spaces in your field names,
you have to encode the names in brackets.

"SELECT ([Asset Number], Description, Serial_Number, Mfg, [Asset Type],
RDCnumber) FROM Assets"

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

slinky said:
OK I double checked and corrected any incident of misspelling or
brackets missing and corrected those.

And now it looks like?
But still the browser brings up
this: (And I know nothing about
reading a stack)

Also, do I have this syntaxed correctly (ignore the '& _'s as they are
just from reformat on paste)?:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Server.MapPath(~/App_Data/Lowes.mdb));" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

No. You have put Server.MapPath inside the string. There it doesn't mean
anything at all. Concatenate the return value from the method into the
string:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
 
S

slinky

I tried this exact paste:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

And it didn't like the format so I redid it to:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data &
_
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

And that didn't work either, so I tried just one long string:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" "Initial
Catalog=Assets;Integrated Security=SSPI")

or:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath & _
(~/App_Data/Lowes.mdb) & ";" "Initial Catalog=Assets;Integrated
Security=SSPI")

Then it doesn't allow the "~" symbol. I see your point about putting
Server.MapPath outside the rest of the code, but I tried these
variations and couldn't get the syntax to be accepted.

Any ideas of what I'm doing wrong? And I really do appreciate your
help for this newbie!
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

slinky said:
I tried this exact paste:

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")

That's only two lines, not three. I just edited the code that you posted.

I forgot the quotes around the string in the call to MapPath.

You really should read up a bit on the basic elements in the
programming, like strings and method calls. If you just copy and paste
code that you don't understand, you won't learn anything.

Code posted in newsgroups and articles often has small mistakes like
this, if you don't understand the code you can't fix those mistakes and
use the code.
 
G

Guest

That's only two lines, not three. I just edited the code that you posted.

I forgot the quotes around the string in the call to MapPath.

You really should read up a bit on the basic elements in the
programming, like strings and method calls. If you just copy and paste
code that you don't understand, you won't learn anything.

Code posted in newsgroups and articles often has small mistakes like
this, if you don't understand the code you can't fix those mistakes and
use the code.

Agree with Göran.

http://groups.google.com/group/micr....aspnet/browse_thread/thread/04fa4e582f3bc1e6
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top