Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Saturday, March 31, 2012

Trim all characters after the first " . " help need...

I need a really basic line of code which i can not find. I need to do is remove ALL characters after and inc the characters "." found in a variable. i have a variable which holds device with DNS name such as E096064-FWSM2.netdevice.companyname.com i want the variable to just hold the name E096064-FWSM2 the extension after the first "." can very greatly so i can not specify all possible options as i just do not know what they are going to be.

really hope someone can help me

paul

code below did the job

DNSnode = Left(fullDNSname, InStr(fullDNSname, ".")-1)

Saturday, March 24, 2012

Trouble with ArrayList and GridView

Hi all,

I am trying to display somedata from a postgres database, and display it using an asp.net page, using a GridView. The basic thing I am doing is, getting data from the database, storing it in an ArrayList, and passing the ArrayList to the DataSource for the GridView.

The problem is the data that I need to display is 3 dimensional. My questions are:

How can I create an ArrayList that can hold 3 columns for each row? How do I populate such an ArrayList? How can I pass this data to the GridView? How can I getHyperlinks on all the values displayed in the first column?

I am a beginner atasp.net. Any help will be appreciated.

Thanks
George

Hey,

The preferred data object for this is a DataTable. Though I don't know if there is ADO.NET support for a postgres database (I don't know anything about that database system), you could still make use of a DataTable, as that works well with the GridView.

The other alternative is that you get the data back from the postgres database and populate it into a business object that contains the three properties of information you are returning. An arraylist can be a list of business objects, which each object has the three properties.


Ok, I tried using the DataTable, so now I am retrieving data from my table, populating the data table and displaying it. This works fine.

But what I need is a query that retrieves data in a 'for' loop, since I need to pass different variables to the query everytime. So I pass a variable, run the query, store the result somewhere(an ArrayList?), then pass the next variable, run the query, append the result to my storage and so on...

I am not sure if we can append data to a DataTable(if we can, I would like to know how). And incase ArrayList is the best option available, how would I be able to create an ArrayList that would contain 3 columns? How can this be displayed in a GridView?

Thanks for the reply. Hoping to get around this problem soon.

George


to add hyper link all you have to do is right click over the grid veiw and select Show Smart Tag >>>

Then in the Smart Tag of the GridVeiw click the Edit columns link

A field wizard will pop, in that make sureAuto-generate field option is checked

In the Available field sectionselect the HyperLinkField and click the Add button

Then Select the HyperLinkField in the selected field section

Inside the HyperLinkField Properties section :-

? In appearrance section make the text to go

? In data section make the DataNagivationUrlFormatString to topic.aspx?TopicId={0}

(Here topic.aspx is the page you wan to redirect and TopicId is the QueryString Variable)

? In data section make the DataNavigationUrlField toTopicId

(This actually specify the value of {0})


At the first, DataTable is the best option for you!

Yes, you can add a DataRow to a DataTable:

// Define a DataTable

DataTable tbl =newDataTable();

// Add your Columns to DataTable

tbl.Columns.Add("Col1");

tbl.Columns.Add("Col2");

// Create a DataRow for this table

DataRow row = tbl.NewRow();

// Set you row values

row[0] ="c1";

row["Col2"] = 25;

// Add row to table

tbl.Rows.Add(row);

Also, you can use Rows of your table in "for" loop:

foreach (DataRow rwin tbl.Rows)

{

Response.Write(rw["Col1"]);

}

or

for (int i = 0; i < tbl.Rows.Count; i++)

{

Response.Write(tbl.Rows[i]["Col2"]);

}


Hello,

Yes, the code above can be used to iterate through a data table. You can also use a DataView to filter the data by using the RowFilter property:

http://msdn2.microsoft.com/en-us/library/system.data.dataview(VS.71).aspx
http://davidhayden.com/blog/dave/archive/2006/02/11/2798.aspx

Tuesday, March 13, 2012

trouble with web forms

im trying to get a table from a microsoft access database on a simple
web form using visual basic.net. ive set up the database as a file
dsn.
this is my connection string:
DBQ=C:\Program Files\Microsoft
Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C:\Program
Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsof
t Access Driver
(*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=C:\Program Files\Common
Files\ODBC\Data
Sources\test2. dsn;MaxBufferSize=2048;MaxScanRows=8;Pag
eTimeout=5;SafeTransac
tions=0;Threads=3;UID=admin;UserCommitSy
nc=Yes;
works fine when i try it with a windows form, however with the webform,
when i try it, i get the following errors because of line69 :
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC
Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000]
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
Access Driver] Could not use '(unknown)'; file already in use. ERROR
[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable
to open registry key 'Temporary (volatile) Jet DSN for process 0x3a4
Thread 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC
Microsoft Access Driver]General error Unable to open registry key
'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
Could not use '(unknown)'; file already in use.
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.Odbc.OdbcException: ERROR [HY000]
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager]
Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
Microsoft Access Driver]General error Unable to open registry key
'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
Could not use '(unknown)'; file already in use. ERROR [HY000]
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
Access Driver]General error Unable to open registry key 'Temporary
(volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
'(unknown)'; file already in use.
Source Error:
Line 67: Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Line 68: DataSet11.Clear()
Line 69: OdbcDataAdapter1.Fill(DataSet11)
Line 70: DataGrid1.DataBind()
Line 71: End Sub
Source File: c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb Line: 69
Stack Trace:
[OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access
Driver]General error Unable to open registry key 'Temporary (volatile)
Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
SQLSetConnectAttr failed
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
'(unknown)'; file already in use.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
'(unknown)'; file already in use.]
System.Data.Odbc.OdbcConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
ConnectionState& originalState)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
TestWeb1.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb:69
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
This is my code:
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()
Me.OdbcSelectCommand1 = New System.Data.Odbc.OdbcCommand
Me.OdbcInsertCommand1 = New System.Data.Odbc.OdbcCommand
Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
Me.OdbcDataAdapter1 = New System.Data.Odbc.OdbcDataAdapter
Me.DataSet11 = New TestWeb1.DataSet1
CType(Me.DataSet11,
System.ComponentModel.ISupportInitialize).BeginInit()
'
'OdbcSelectCommand1
'
Me.OdbcSelectCommand1.CommandText = "SELECT ShipperID,
CompanyName, Phone FROM Shippers"
Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
'
'OdbcInsertCommand1
'
Me.OdbcInsertCommand1.CommandText = "INSERT INTO
Shippers(CompanyName, Phone) VALUES (?, ?)"
Me.OdbcInsertCommand1.Connection = Me.OdbcConnection1
Me.OdbcInsertCommand1.Parameters.Add(New
System.Data.Odbc.OdbcParameter("CompanyName",
System.Data.Odbc.OdbcType.NVarChar, 40, "CompanyName"))
Me.OdbcInsertCommand1.Parameters.Add(New
System.Data.Odbc.OdbcParameter("Phone",
System.Data.Odbc.OdbcType.NVarChar, 24, "Phone"))
'
'OdbcConnection1
'
Me.OdbcConnection1.ConnectionString =
" PageTimeout=5;MaxScanRows=8;DefaultDir=C
:\Program Files\Microsoft
Office\OFFICE11" & _
"\SAMPLES;FILEDSN=C:\Program Files\Common Files\ODBC\Data
Sources\test2.dsn;Drive" & _
"rId=25;DBQ=C:\Program Files\Microsoft
Office\OFFICE11\SAMPLES\Northwind.mdb;User" & _
"CommitSync=Yes;FIL=MS Access;UID=admin;Driver={Microsoft
Access Driver (*.mdb)};" & _
" MaxBufferSize=2048;Threads=3;SafeTransac
tions=0"
'
'OdbcDataAdapter1
'
Me.OdbcDataAdapter1.InsertCommand = Me.OdbcInsertCommand1
Me.OdbcDataAdapter1.SelectCommand = Me.OdbcSelectCommand1
Me.OdbcDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "Shippers", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("ShipperID", "ShipperID"), New
System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New
System.Data.Common.DataColumnMapping("Phone", "Phone")})})
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New
System.Globalization.CultureInfo("en-IE")
CType(Me.DataSet11,
System.ComponentModel.ISupportInitialize).EndInit()
End Sub
Protected WithEvents OdbcSelectCommand1 As
System.Data.Odbc.OdbcCommand
Protected WithEvents OdbcInsertCommand1 As
System.Data.Odbc.OdbcCommand
Protected WithEvents OdbcConnection1 As
System.Data.Odbc.OdbcConnection
Protected WithEvents OdbcDataAdapter1 As
System.Data.Odbc.OdbcDataAdapter
Protected WithEvents DataSet11 As TestWeb1.DataSet1
Protected WithEvents DataGrid1 As
System.Web.UI.WebControls.DataGrid
'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
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataSet11.Clear()
OdbcDataAdapter1.Fill(DataSet11)
DataGrid1.DataBind()
End Sub
End Class
iv been tryin to sort this for a couple of days but am completely at a
loss as to how to sort this. Can anyone help?Well, I could be wrong since I haven't seen every detail of your setup or
code, but that looks like a very strange connection string. Here are some
things I would check:
1. Directories rarely start with the drive letter (C:) when dealing with the
web.
2. Your connection string looks much more complicated than necessary. Here
is the line that I use to create my connections in all the websites I have
created that use Access databases (and they have been on different servers,
so unless you have a strange setup I'm guessing it will work for you too):
Dim myconnection As New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("/mydatabase.mdb"))
Just modify the last part to be the correct path to your *.mdb file.
3. Check the permissions on the *.mdb file to make sure ASPNET has
permission to access it.
Although something that I am kind of getting the impression of is that you
require a more full-featured and secure database, Access was not really
intended for web-related stuff. If you have a very big company or plan to
use the database heavily, I would put in the effort and money to buy either
Oracle or SQL Server (you would probably prefer SQL Server since you are
coming from Access). I am only a student, but ASP.NET and Web Development
are my areas of concentration and these are things I have been taught and
gained through experience and articles I have read. Good Luck!
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
<somersbar@.yahoo.com> wrote in message
news:1140106859.776998.150120@.z14g2000cwz.googlegroups.com...
> im trying to get a table from a microsoft access database on a simple
> web form using visual basic.net. ive set up the database as a file
> dsn.
> this is my connection string:
> DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C:\Program
> Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsof
t Access Driver
> (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=C:\Program Files\Common
> Files\ODBC\Data
> Sources\test2. dsn;MaxBufferSize=2048;MaxScanRows=8;Pag
eTimeout=5;SafeTrans
actions=0;Threads=3;UID=admin;UserCommit
Sync=Yes;
>
> works fine when i try it with a windows form, however with the webform,
> when i try it, i get the following errors because of line69 :
>
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC
> Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver] Could not use '(unknown)'; file already in use. ERROR
> [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable
> to open registry key 'Temporary (volatile) Jet DSN for process 0x3a4
> Thread 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use.
> 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.Odbc.OdbcException: ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager]
> Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use. ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver]General error Unable to open registry key 'Temporary
> (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> Source Error:
> Line 67: Private Sub Page_Load(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles MyBase.Load
> Line 68: DataSet11.Clear()
> Line 69: OdbcDataAdapter1.Fill(DataSet11)
> Line 70: DataGrid1.DataBind()
> Line 71: End Sub
>
> Source File: c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb Line: 69
> Stack Trace:
> [OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access
> Driver]General error Unable to open registry key 'Temporary (volatile)
> Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
> SQLSetConnectAttr failed
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.]
> System.Data.Odbc.OdbcConnection.Open()
> System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
> ConnectionState& originalState)
> System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
> TestWeb1.WebForm1.Page_Load(Object sender, EventArgs e) in
> c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb:69
> System.Web.UI.Control.OnLoad(EventArgs e)
> System.Web.UI.Control.LoadRecursive()
> System.Web.UI.Page.ProcessRequestMain()
>
>
> This is my code:
> 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()
> Me.OdbcSelectCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcInsertCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
> Me.OdbcDataAdapter1 = New System.Data.Odbc.OdbcDataAdapter
> Me.DataSet11 = New TestWeb1.DataSet1
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).BeginInit()
> '
> 'OdbcSelectCommand1
> '
> Me.OdbcSelectCommand1.CommandText = "SELECT ShipperID,
> CompanyName, Phone FROM Shippers"
> Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
> '
> 'OdbcInsertCommand1
> '
> Me.OdbcInsertCommand1.CommandText = "INSERT INTO
> Shippers(CompanyName, Phone) VALUES (?, ?)"
> Me.OdbcInsertCommand1.Connection = Me.OdbcConnection1
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("CompanyName",
> System.Data.Odbc.OdbcType.NVarChar, 40, "CompanyName"))
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("Phone",
> System.Data.Odbc.OdbcType.NVarChar, 24, "Phone"))
> '
> 'OdbcConnection1
> '
> Me.OdbcConnection1.ConnectionString =
> " PageTimeout=5;MaxScanRows=8;DefaultDir=C
:\Program Files\Microsoft
> Office\OFFICE11" & _
> "\SAMPLES;FILEDSN=C:\Program Files\Common Files\ODBC\Data
> Sources\test2.dsn;Drive" & _
> "rId=25;DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;User" & _
> "CommitSync=Yes;FIL=MS Access;UID=admin;Driver={Microsoft
> Access Driver (*.mdb)};" & _
> " MaxBufferSize=2048;Threads=3;SafeTransac
tions=0"
> '
> 'OdbcDataAdapter1
> '
> Me.OdbcDataAdapter1.InsertCommand = Me.OdbcInsertCommand1
> Me.OdbcDataAdapter1.SelectCommand = Me.OdbcSelectCommand1
> Me.OdbcDataAdapter1.TableMappings.AddRange(New
> System.Data.Common.DataTableMapping() {New
> System.Data.Common.DataTableMapping("Table", "Shippers", New
> System.Data.Common.DataColumnMapping() {New
> System.Data.Common.DataColumnMapping("ShipperID", "ShipperID"), New
> System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New
> System.Data.Common.DataColumnMapping("Phone", "Phone")})})
> '
> 'DataSet11
> '
> Me.DataSet11.DataSetName = "DataSet1"
> Me.DataSet11.Locale = New
> System.Globalization.CultureInfo("en-IE")
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).EndInit()
> End Sub
> Protected WithEvents OdbcSelectCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcInsertCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcConnection1 As
> System.Data.Odbc.OdbcConnection
> Protected WithEvents OdbcDataAdapter1 As
> System.Data.Odbc.OdbcDataAdapter
> Protected WithEvents DataSet11 As TestWeb1.DataSet1
> Protected WithEvents DataGrid1 As
> System.Web.UI.WebControls.DataGrid
> '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
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> DataSet11.Clear()
> OdbcDataAdapter1.Fill(DataSet11)
> DataGrid1.DataBind()
> End Sub
> End Class
>
> iv been tryin to sort this for a couple of days but am completely at a
> loss as to how to sort this. Can anyone help?
>
Do you have Office installed on your server?
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."
<somersbar@.yahoo.com> wrote in message
news:1140106859.776998.150120@.z14g2000cwz.googlegroups.com...
> im trying to get a table from a microsoft access database on a simple
> web form using visual basic.net. ive set up the database as a file
> dsn.
> this is my connection string:
> DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C:\Program
> Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsof
t Access Driver
> (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=C:\Program Files\Common
> Files\ODBC\Data
> Sources\test2. dsn;MaxBufferSize=2048;MaxScanRows=8;Pag
eTimeout=5;SafeTrans
actions=0;Threads=3;UID=admin;UserCommit
Sync=Yes;
>
> works fine when i try it with a windows form, however with the webform,
> when i try it, i get the following errors because of line69 :
>
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC
> Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver] Could not use '(unknown)'; file already in use. ERROR
> [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable
> to open registry key 'Temporary (volatile) Jet DSN for process 0x3a4
> Thread 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use.
> 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.Odbc.OdbcException: ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager]
> Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use. ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver]General error Unable to open registry key 'Temporary
> (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> Source Error:
> Line 67: Private Sub Page_Load(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles MyBase.Load
> Line 68: DataSet11.Clear()
> Line 69: OdbcDataAdapter1.Fill(DataSet11)
> Line 70: DataGrid1.DataBind()
> Line 71: End Sub
>
> Source File: c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb Line: 69
> Stack Trace:
> [OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access
> Driver]General error Unable to open registry key 'Temporary (volatile)
> Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
> SQLSetConnectAttr failed
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.]
> System.Data.Odbc.OdbcConnection.Open()
> System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
> ConnectionState& originalState)
> System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
> TestWeb1.WebForm1.Page_Load(Object sender, EventArgs e) in
> c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb:69
> System.Web.UI.Control.OnLoad(EventArgs e)
> System.Web.UI.Control.LoadRecursive()
> System.Web.UI.Page.ProcessRequestMain()
>
>
> This is my code:
> 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()
> Me.OdbcSelectCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcInsertCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
> Me.OdbcDataAdapter1 = New System.Data.Odbc.OdbcDataAdapter
> Me.DataSet11 = New TestWeb1.DataSet1
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).BeginInit()
> '
> 'OdbcSelectCommand1
> '
> Me.OdbcSelectCommand1.CommandText = "SELECT ShipperID,
> CompanyName, Phone FROM Shippers"
> Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
> '
> 'OdbcInsertCommand1
> '
> Me.OdbcInsertCommand1.CommandText = "INSERT INTO
> Shippers(CompanyName, Phone) VALUES (?, ?)"
> Me.OdbcInsertCommand1.Connection = Me.OdbcConnection1
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("CompanyName",
> System.Data.Odbc.OdbcType.NVarChar, 40, "CompanyName"))
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("Phone",
> System.Data.Odbc.OdbcType.NVarChar, 24, "Phone"))
> '
> 'OdbcConnection1
> '
> Me.OdbcConnection1.ConnectionString =
> " PageTimeout=5;MaxScanRows=8;DefaultDir=C
:\Program Files\Microsoft
> Office\OFFICE11" & _
> "\SAMPLES;FILEDSN=C:\Program Files\Common Files\ODBC\Data
> Sources\test2.dsn;Drive" & _
> "rId=25;DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;User" & _
> "CommitSync=Yes;FIL=MS Access;UID=admin;Driver={Microsoft
> Access Driver (*.mdb)};" & _
> " MaxBufferSize=2048;Threads=3;SafeTransac
tions=0"
> '
> 'OdbcDataAdapter1
> '
> Me.OdbcDataAdapter1.InsertCommand = Me.OdbcInsertCommand1
> Me.OdbcDataAdapter1.SelectCommand = Me.OdbcSelectCommand1
> Me.OdbcDataAdapter1.TableMappings.AddRange(New
> System.Data.Common.DataTableMapping() {New
> System.Data.Common.DataTableMapping("Table", "Shippers", New
> System.Data.Common.DataColumnMapping() {New
> System.Data.Common.DataColumnMapping("ShipperID", "ShipperID"), New
> System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New
> System.Data.Common.DataColumnMapping("Phone", "Phone")})})
> '
> 'DataSet11
> '
> Me.DataSet11.DataSetName = "DataSet1"
> Me.DataSet11.Locale = New
> System.Globalization.CultureInfo("en-IE")
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).EndInit()
> End Sub
> Protected WithEvents OdbcSelectCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcInsertCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcConnection1 As
> System.Data.Odbc.OdbcConnection
> Protected WithEvents OdbcDataAdapter1 As
> System.Data.Odbc.OdbcDataAdapter
> Protected WithEvents DataSet11 As TestWeb1.DataSet1
> Protected WithEvents DataGrid1 As
> System.Web.UI.WebControls.DataGrid
> '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
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> DataSet11.Clear()
> OdbcDataAdapter1.Fill(DataSet11)
> DataGrid1.DataBind()
> End Sub
> End Class
>
> iv been tryin to sort this for a couple of days but am completely at a
> loss as to how to sort this. Can anyone help?
>

trouble with web forms

im trying to get a table from a microsoft access database on a simple
web form using visual basic.net. ive set up the database as a file
dsn.

this is my connection string:

DBQ=C:\Program Files\Microsoft
Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C :\Program
Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsoft Access Driver
(*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=C:\Program Files\Common
Files\ODBC\Data
Sources\test2.dsn;MaxBufferSize=2048;MaxScanRows=8 ;PageTimeout=5;SafeTransactions=0;Threads=3;UID=ad min;UserCommitSync=Yes;

works fine when i try it with a windows form, however with the webform,
when i try it, i get the following errors because of line69 :

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC
Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000]
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
Access Driver] Could not use '(unknown)'; file already in use. ERROR
[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable
to open registry key 'Temporary (volatile) Jet DSN for process 0x3a4
Thread 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC
Microsoft Access Driver]General error Unable to open registry key
'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
Could not use '(unknown)'; file already in use.

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.Odbc.OdbcException: ERROR [HY000]
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager]
Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
Microsoft Access Driver]General error Unable to open registry key
'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
Could not use '(unknown)'; file already in use. ERROR [HY000]
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
Access Driver]General error Unable to open registry key 'Temporary
(volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
'(unknown)'; file already in use.

Source Error:

Line 67: Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Line 68: DataSet11.Clear()
Line 69: OdbcDataAdapter1.Fill(DataSet11)
Line 70: DataGrid1.DataBind()
Line 71: End Sub

Source File: c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb Line: 69

Stack Trace:

[OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access
Driver]General error Unable to open registry key 'Temporary (volatile)
Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
SQLSetConnectAttr failed
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
'(unknown)'; file already in use.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
'(unknown)'; file already in use.]
System.Data.Odbc.OdbcConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection,
ConnectionState& originalState)
System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
TestWeb1.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb:69
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

This is my code:

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()
Me.OdbcSelectCommand1 = New System.Data.Odbc.OdbcCommand
Me.OdbcInsertCommand1 = New System.Data.Odbc.OdbcCommand
Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
Me.OdbcDataAdapter1 = New System.Data.Odbc.OdbcDataAdapter
Me.DataSet11 = New TestWeb1.DataSet1
CType(Me.DataSet11,
System.ComponentModel.ISupportInitialize).BeginIni t()
'
'OdbcSelectCommand1
'
Me.OdbcSelectCommand1.CommandText = "SELECT ShipperID,
CompanyName, Phone FROM Shippers"
Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
'
'OdbcInsertCommand1
'
Me.OdbcInsertCommand1.CommandText = "INSERT INTO
Shippers(CompanyName, Phone) VALUES (?, ?)"
Me.OdbcInsertCommand1.Connection = Me.OdbcConnection1
Me.OdbcInsertCommand1.Parameters.Add(New
System.Data.Odbc.OdbcParameter("CompanyName",
System.Data.Odbc.OdbcType.NVarChar, 40, "CompanyName"))
Me.OdbcInsertCommand1.Parameters.Add(New
System.Data.Odbc.OdbcParameter("Phone",
System.Data.Odbc.OdbcType.NVarChar, 24, "Phone"))
'
'OdbcConnection1
'
Me.OdbcConnection1.ConnectionString =
"PageTimeout=5;MaxScanRows=8;DefaultDir=C:\Program Files\Microsoft
Office\OFFICE11" & _
"\SAMPLES;FILEDSN=C:\Program Files\Common Files\ODBC\Data
Sources\test2.dsn;Drive" & _
"rId=25;DBQ=C:\Program Files\Microsoft
Office\OFFICE11\SAMPLES\Northwind.mdb;User" & _
"CommitSync=Yes;FIL=MS Access;UID=admin;Driver={Microsoft
Access Driver (*.mdb)};" & _
"MaxBufferSize=2048;Threads=3;SafeTransactions=0"
'
'OdbcDataAdapter1
'
Me.OdbcDataAdapter1.InsertCommand = Me.OdbcInsertCommand1
Me.OdbcDataAdapter1.SelectCommand = Me.OdbcSelectCommand1
Me.OdbcDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "Shippers", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("ShipperID", "ShipperID"), New
System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New
System.Data.Common.DataColumnMapping("Phone", "Phone")})})
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New
System.Globalization.CultureInfo("en-IE")
CType(Me.DataSet11,
System.ComponentModel.ISupportInitialize).EndInit( )

End Sub
Protected WithEvents OdbcSelectCommand1 As
System.Data.Odbc.OdbcCommand
Protected WithEvents OdbcInsertCommand1 As
System.Data.Odbc.OdbcCommand
Protected WithEvents OdbcConnection1 As
System.Data.Odbc.OdbcConnection
Protected WithEvents OdbcDataAdapter1 As
System.Data.Odbc.OdbcDataAdapter
Protected WithEvents DataSet11 As TestWeb1.DataSet1
Protected WithEvents DataGrid1 As
System.Web.UI.WebControls.DataGrid

'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

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
DataSet11.Clear()
OdbcDataAdapter1.Fill(DataSet11)
DataGrid1.DataBind()
End Sub

End Class

iv been tryin to sort this for a couple of days but am completely at a
loss as to how to sort this. Can anyone help?Well, I could be wrong since I haven't seen every detail of your setup or
code, but that looks like a very strange connection string. Here are some
things I would check:

1. Directories rarely start with the drive letter (C:) when dealing with the
web.
2. Your connection string looks much more complicated than necessary. Here
is the line that I use to create my connections in all the websites I have
created that use Access databases (and they have been on different servers,
so unless you have a strange setup I'm guessing it will work for you too):

Dim myconnection As New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
Server.MapPath("/mydatabase.mdb"))

Just modify the last part to be the correct path to your *.mdb file.

3. Check the permissions on the *.mdb file to make sure ASPNET has
permission to access it.

Although something that I am kind of getting the impression of is that you
require a more full-featured and secure database, Access was not really
intended for web-related stuff. If you have a very big company or plan to
use the database heavily, I would put in the effort and money to buy either
Oracle or SQL Server (you would probably prefer SQL Server since you are
coming from Access). I am only a student, but ASP.NET and Web Development
are my areas of concentration and these are things I have been taught and
gained through experience and articles I have read. Good Luck!
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/

<somersbar@.yahoo.com> wrote in message
news:1140106859.776998.150120@.z14g2000cwz.googlegr oups.com...
> im trying to get a table from a microsoft access database on a simple
> web form using visual basic.net. ive set up the database as a file
> dsn.
> this is my connection string:
> DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C :\Program
> Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsoft Access Driver
> (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=C:\Program Files\Common
> Files\ODBC\Data
> Sources\test2.dsn;MaxBufferSize=2048;MaxScanRows=8 ;PageTimeout=5;SafeTransactions=0;Threads=3;UID=ad min;UserCommitSync=Yes;
>
> works fine when i try it with a windows form, however with the webform,
> when i try it, i get the following errors because of line69 :
>
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC
> Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver] Could not use '(unknown)'; file already in use. ERROR
> [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable
> to open registry key 'Temporary (volatile) Jet DSN for process 0x3a4
> Thread 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use.
> 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.Odbc.OdbcException: ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager]
> Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use. ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver]General error Unable to open registry key 'Temporary
> (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> Source Error:
> Line 67: Private Sub Page_Load(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles MyBase.Load
> Line 68: DataSet11.Clear()
> Line 69: OdbcDataAdapter1.Fill(DataSet11)
> Line 70: DataGrid1.DataBind()
> Line 71: End Sub
>
> Source File: c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb Line: 69
> Stack Trace:
> [OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access
> Driver]General error Unable to open registry key 'Temporary (volatile)
> Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
> SQLSetConnectAttr failed
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.]
> System.Data.Odbc.OdbcConnection.Open()
> System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection,
> ConnectionState& originalState)
> System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
> TestWeb1.WebForm1.Page_Load(Object sender, EventArgs e) in
> c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb:69
> System.Web.UI.Control.OnLoad(EventArgs e)
> System.Web.UI.Control.LoadRecursive()
> System.Web.UI.Page.ProcessRequestMain()
>
>
> This is my code:
> 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()
> Me.OdbcSelectCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcInsertCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
> Me.OdbcDataAdapter1 = New System.Data.Odbc.OdbcDataAdapter
> Me.DataSet11 = New TestWeb1.DataSet1
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).BeginIni t()
> '
> 'OdbcSelectCommand1
> '
> Me.OdbcSelectCommand1.CommandText = "SELECT ShipperID,
> CompanyName, Phone FROM Shippers"
> Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
> '
> 'OdbcInsertCommand1
> '
> Me.OdbcInsertCommand1.CommandText = "INSERT INTO
> Shippers(CompanyName, Phone) VALUES (?, ?)"
> Me.OdbcInsertCommand1.Connection = Me.OdbcConnection1
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("CompanyName",
> System.Data.Odbc.OdbcType.NVarChar, 40, "CompanyName"))
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("Phone",
> System.Data.Odbc.OdbcType.NVarChar, 24, "Phone"))
> '
> 'OdbcConnection1
> '
> Me.OdbcConnection1.ConnectionString =
> "PageTimeout=5;MaxScanRows=8;DefaultDir=C:\Program Files\Microsoft
> Office\OFFICE11" & _
> "\SAMPLES;FILEDSN=C:\Program Files\Common Files\ODBC\Data
> Sources\test2.dsn;Drive" & _
> "rId=25;DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;User" & _
> "CommitSync=Yes;FIL=MS Access;UID=admin;Driver={Microsoft
> Access Driver (*.mdb)};" & _
> "MaxBufferSize=2048;Threads=3;SafeTransactions=0"
> '
> 'OdbcDataAdapter1
> '
> Me.OdbcDataAdapter1.InsertCommand = Me.OdbcInsertCommand1
> Me.OdbcDataAdapter1.SelectCommand = Me.OdbcSelectCommand1
> Me.OdbcDataAdapter1.TableMappings.AddRange(New
> System.Data.Common.DataTableMapping() {New
> System.Data.Common.DataTableMapping("Table", "Shippers", New
> System.Data.Common.DataColumnMapping() {New
> System.Data.Common.DataColumnMapping("ShipperID", "ShipperID"), New
> System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New
> System.Data.Common.DataColumnMapping("Phone", "Phone")})})
> '
> 'DataSet11
> '
> Me.DataSet11.DataSetName = "DataSet1"
> Me.DataSet11.Locale = New
> System.Globalization.CultureInfo("en-IE")
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).EndInit( )
> End Sub
> Protected WithEvents OdbcSelectCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcInsertCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcConnection1 As
> System.Data.Odbc.OdbcConnection
> Protected WithEvents OdbcDataAdapter1 As
> System.Data.Odbc.OdbcDataAdapter
> Protected WithEvents DataSet11 As TestWeb1.DataSet1
> Protected WithEvents DataGrid1 As
> System.Web.UI.WebControls.DataGrid
> '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
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> DataSet11.Clear()
> OdbcDataAdapter1.Fill(DataSet11)
> DataGrid1.DataBind()
> End Sub
> End Class
>
> iv been tryin to sort this for a couple of days but am completely at a
> loss as to how to sort this. Can anyone help?
Do you have Office installed on your server?
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<somersbar@.yahoo.com> wrote in message
news:1140106859.776998.150120@.z14g2000cwz.googlegr oups.com...
> im trying to get a table from a microsoft access database on a simple
> web form using visual basic.net. ive set up the database as a file
> dsn.
> this is my connection string:
> DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C :\Program
> Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsoft Access Driver
> (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=C:\Program Files\Common
> Files\ODBC\Data
> Sources\test2.dsn;MaxBufferSize=2048;MaxScanRows=8 ;PageTimeout=5;SafeTransactions=0;Threads=3;UID=ad min;UserCommitSync=Yes;
>
> works fine when i try it with a windows form, however with the webform,
> when i try it, i get the following errors because of line69 :
>
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC
> Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver] Could not use '(unknown)'; file already in use. ERROR
> [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable
> to open registry key 'Temporary (volatile) Jet DSN for process 0x3a4
> Thread 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use.
> 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.Odbc.OdbcException: ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager]
> Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
> Microsoft Access Driver]General error Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC
> 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
> Could not use '(unknown)'; file already in use. ERROR [HY000]
> [Microsoft][ODBC Microsoft Access Driver]General error Unable to open
> registry key 'Temporary (volatile) Jet DSN for process 0x3a4 Thread
> 0x720 DBC 0x437aa4 Jet'. ERROR [HY000] [Microsoft][ODBC Microsoft
> Access Driver]General error Unable to open registry key 'Temporary
> (volatile) Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> Source Error:
> Line 67: Private Sub Page_Load(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles MyBase.Load
> Line 68: DataSet11.Clear()
> Line 69: OdbcDataAdapter1.Fill(DataSet11)
> Line 70: DataGrid1.DataBind()
> Line 71: End Sub
>
> Source File: c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb Line: 69
> Stack Trace:
> [OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access
> Driver]General error Unable to open registry key 'Temporary (volatile)
> Jet DSN for process 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
> SQLSetConnectAttr failed
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
> 0x3a4 Thread 0x720 DBC 0x437aa4 Jet'.
> ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use
> '(unknown)'; file already in use.]
> System.Data.Odbc.OdbcConnection.Open()
> System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection,
> ConnectionState& originalState)
> System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
> TestWeb1.WebForm1.Page_Load(Object sender, EventArgs e) in
> c:\inetpub\wwwroot\TestWeb1\WebForm1.aspx.vb:69
> System.Web.UI.Control.OnLoad(EventArgs e)
> System.Web.UI.Control.LoadRecursive()
> System.Web.UI.Page.ProcessRequestMain()
>
>
> This is my code:
> 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()
> Me.OdbcSelectCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcInsertCommand1 = New System.Data.Odbc.OdbcCommand
> Me.OdbcConnection1 = New System.Data.Odbc.OdbcConnection
> Me.OdbcDataAdapter1 = New System.Data.Odbc.OdbcDataAdapter
> Me.DataSet11 = New TestWeb1.DataSet1
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).BeginIni t()
> '
> 'OdbcSelectCommand1
> '
> Me.OdbcSelectCommand1.CommandText = "SELECT ShipperID,
> CompanyName, Phone FROM Shippers"
> Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
> '
> 'OdbcInsertCommand1
> '
> Me.OdbcInsertCommand1.CommandText = "INSERT INTO
> Shippers(CompanyName, Phone) VALUES (?, ?)"
> Me.OdbcInsertCommand1.Connection = Me.OdbcConnection1
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("CompanyName",
> System.Data.Odbc.OdbcType.NVarChar, 40, "CompanyName"))
> Me.OdbcInsertCommand1.Parameters.Add(New
> System.Data.Odbc.OdbcParameter("Phone",
> System.Data.Odbc.OdbcType.NVarChar, 24, "Phone"))
> '
> 'OdbcConnection1
> '
> Me.OdbcConnection1.ConnectionString =
> "PageTimeout=5;MaxScanRows=8;DefaultDir=C:\Program Files\Microsoft
> Office\OFFICE11" & _
> "\SAMPLES;FILEDSN=C:\Program Files\Common Files\ODBC\Data
> Sources\test2.dsn;Drive" & _
> "rId=25;DBQ=C:\Program Files\Microsoft
> Office\OFFICE11\SAMPLES\Northwind.mdb;User" & _
> "CommitSync=Yes;FIL=MS Access;UID=admin;Driver={Microsoft
> Access Driver (*.mdb)};" & _
> "MaxBufferSize=2048;Threads=3;SafeTransactions=0"
> '
> 'OdbcDataAdapter1
> '
> Me.OdbcDataAdapter1.InsertCommand = Me.OdbcInsertCommand1
> Me.OdbcDataAdapter1.SelectCommand = Me.OdbcSelectCommand1
> Me.OdbcDataAdapter1.TableMappings.AddRange(New
> System.Data.Common.DataTableMapping() {New
> System.Data.Common.DataTableMapping("Table", "Shippers", New
> System.Data.Common.DataColumnMapping() {New
> System.Data.Common.DataColumnMapping("ShipperID", "ShipperID"), New
> System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New
> System.Data.Common.DataColumnMapping("Phone", "Phone")})})
> '
> 'DataSet11
> '
> Me.DataSet11.DataSetName = "DataSet1"
> Me.DataSet11.Locale = New
> System.Globalization.CultureInfo("en-IE")
> CType(Me.DataSet11,
> System.ComponentModel.ISupportInitialize).EndInit( )
> End Sub
> Protected WithEvents OdbcSelectCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcInsertCommand1 As
> System.Data.Odbc.OdbcCommand
> Protected WithEvents OdbcConnection1 As
> System.Data.Odbc.OdbcConnection
> Protected WithEvents OdbcDataAdapter1 As
> System.Data.Odbc.OdbcDataAdapter
> Protected WithEvents DataSet11 As TestWeb1.DataSet1
> Protected WithEvents DataGrid1 As
> System.Web.UI.WebControls.DataGrid
> '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
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> DataSet11.Clear()
> OdbcDataAdapter1.Fill(DataSet11)
> DataGrid1.DataBind()
> End Sub
> End Class
>
> iv been tryin to sort this for a couple of days but am completely at a
> loss as to how to sort this. Can anyone help?