Showing posts with label table. Show all posts
Showing posts with label table. Show all posts

Saturday, March 31, 2012

Trim string to fit in fixed width Table Cell [Edited by Adec, moderator]

I have the following BIG problemSmile [:)]
The column of datagrid is bind to a database field.
If lenght of string is bigger than the column width i want to trim the string.
No metter if the trimmed word has sense.
I would like to know if anyone knows if there is a way to calculate
string width in pixel in connection to font size used in that particular cell.
You can check the string size and do what you need to with it in your DataGridItemCreated event handler.
that's ok for the position where check, but the problem is how measure the width in pixel of the string:-)
Your getting confused, and making this to complicated. You dont measure strings in pixels, you measure strings in Charatchers, figure out how many charatchers will fit in the column of your datagrid, and trim the string to that amount of chars, I would recomend trimming it to 3 less chars than will fit and appending on a ... so that users know it's been trimmed.
Remember, capital letters take up more space than lower case ones, and different ascii chars can take up a space and a half in some cases purley literally speaking, like the @. symbol.

I would suggest you use sql to get the substring - select substring(myfield, 1, 10) as myfield from my table. This gets the first 10 characters. To add the "..." then select substring(myfield, 1, 7)+'...' as myfield from my table


It is ok, i will follow your indication. But still look for a method like TextWidth("...") to use in application.
Thanks. Best Regards

Monday, March 26, 2012

Trouble getting row count from DataReader

I am using the DataReader to populate an ASP table dynamically. I would
like to set the tables "visible" property based on the the data from my
query. For example, if I have at least one row of data, I will set visible
to true, otherwise, false.

How get I find out if I have at least one row of data? The code below is
from the CodeBehind of my asp form.

*****************************
OracleConnection conn = new OracleConnection(ConnectionString);
OracleCommand cmd = new OracleCommand("select * from customer where name =
'BOB', conn);
try
{
conn.Open();
IDataReader reader = cmd.ExecuteReader();
_grid.DataSource = reader;
_grid.DataBind();
}
finally
{
conn.Dispose();
}
*****************************

Thanks,
KevinI think your only option on a DataReader is to use the .Read property. It
returns false if it can't produce a record.

Otherwise, a dataset is necessary to get the actual record count.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz

"Kevin" <kevin@.spammers_die.com> wrote in message
news:OFV8NLZxDHA.2304@.TK2MSFTNGP12.phx.gbl...
> I am using the DataReader to populate an ASP table dynamically. I would
> like to set the tables "visible" property based on the the data from my
> query. For example, if I have at least one row of data, I will set
visible
> to true, otherwise, false.
> How get I find out if I have at least one row of data? The code below is
> from the CodeBehind of my asp form.
> *****************************
> OracleConnection conn = new OracleConnection(ConnectionString);
> OracleCommand cmd = new OracleCommand("select * from customer where name =
> 'BOB', conn);
> try
> {
> conn.Open();
> IDataReader reader = cmd.ExecuteReader();
> _grid.DataSource = reader;
> _grid.DataBind();
> }
> finally
> {
> conn.Dispose();
> }
> *****************************
> Thanks,
> Kevin
Thanks Jerry, that was exactly what I needed.

Kevin

"Jerry Boone" <jerry@.antech.biz.killspam> wrote in message
news:mkmEb.1432$C21.627@.newssvr22.news.prodigy.com ...
> I think your only option on a DataReader is to use the .Read property. It
> returns false if it can't produce a record.
> Otherwise, a dataset is necessary to get the actual record count.
> --
> Jerry Boone
> Analytical Technologies, Inc.
> http://www.antech.biz
>
> "Kevin" <kevin@.spammers_die.com> wrote in message
> news:OFV8NLZxDHA.2304@.TK2MSFTNGP12.phx.gbl...
> > I am using the DataReader to populate an ASP table dynamically. I would
> > like to set the tables "visible" property based on the the data from my
> > query. For example, if I have at least one row of data, I will set
> visible
> > to true, otherwise, false.
> > How get I find out if I have at least one row of data? The code below
is
> > from the CodeBehind of my asp form.
> > *****************************
> > OracleConnection conn = new OracleConnection(ConnectionString);
> > OracleCommand cmd = new OracleCommand("select * from customer where name
=
> > 'BOB', conn);
> > try
> > {
> > conn.Open();
> > IDataReader reader = cmd.ExecuteReader();
> > _grid.DataSource = reader;
> > _grid.DataBind();
> > }
> > finally
> > {
> > conn.Dispose();
> > }
> > *****************************
> > Thanks,
> > Kevin

Tuesday, March 13, 2012

Trouble with Table borders

Hello
I seem to have a re-occuring problem with tables.
Every tiime i create a new table in my code (Table x = new Table();) it
creates in the final code the browser gets the attribute 'border="0"'.(i
prefer putting my styles in a seprate css file)
Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
nothing seems to work.even changing the Table.BorderWidth property creates a
'style="border-width:x"' and stucks me with the 'border="0"'.
It happens even when i create classes derived from Table.
Please help me,it's really annoying.
Thank you.It's hard-coded in the table creation - unfortunetly. But I don't see why
it'd be causing problems with your css decleration? if you do
<table border="0" class="Blah"> and the Blah class defines a border, it
ought to apply it reguarless of what the border says..
Karl
--
http://www.openmymind.net/
"ThePinkPanther" <ThePinkPanther@.discussions.microsoft.com> wrote in message
news:E9E18BBB-B846-40B3-AAD4-A16272C96D68@.microsoft.com...
> Hello
> I seem to have a re-occuring problem with tables.
> Every tiime i create a new table in my code (Table x = new Table();) it
> creates in the final code the browser gets the attribute 'border="0"'.(i
> prefer putting my styles in a seprate css file)
> Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
> nothing seems to work.even changing the Table.BorderWidth property creates
> a
> 'style="border-width:x"' and stucks me with the 'border="0"'.
> It happens even when i create classes derived from Table.
> Please help me,it's really annoying.
> Thank you.
> It's hard-coded in the table creation - unfortunetly. But I don't see why
> it'd be causing problems with your css decleration? if you do

> <table border="0" class="Blah"> and the Blah class defines a border, it
> ought to apply it reguarless of what the border says..
Not true, CSS properties are overriden by inline styles. Not very
helpful, I know.
Well, I'm willing to admit that i'm wrong...but...
I agree that external css properties are overriden by inline styles, but
border="0" isn't an inline style, it's an attribute decleration which ARE
overriden by any styles (inline or external).
so if you do:
<table border="0">
<tr><td>asdsa</td></tr>
</table>
and you create a style in a css:
table
{
border:1px solid #000;
}
you WILL see the border
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Flinky Wisty Pomm" <Pathogenix@.gmail.com> wrote in message
news:1139834577.520780.250200@.g47g2000cwa.googlegroups.com...
>
> Not true, CSS properties are overriden by inline styles. Not very
> helpful, I know.
>
Object withdrawn :)
Always happy to be proven wrong.

Trouble with Table borders

Hello
I seem to have a re-occuring problem with tables.
Every tiime i create a new table in my code (Table x = new Table();) it
creates in the final code the browser gets the attribute 'border="0"'.(i
prefer putting my styles in a seprate css file)
Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
nothing seems to work.even changing the Table.BorderWidth property creates a
'style="border-width:x"' and stucks me with the 'border="0"'.
It happens even when i create classes derived from Table.

Please help me,it's really annoying.
Thank you.It's hard-coded in the table creation - unfortunetly. But I don't see why
it'd be causing problems with your css decleration? if you do

<table border="0" class="Blah"> and the Blah class defines a border, it
ought to apply it reguarless of what the border says..

Karl
--
http://www.openmymind.net/

"ThePinkPanther" <ThePinkPanther@.discussions.microsoft.com> wrote in message
news:E9E18BBB-B846-40B3-AAD4-A16272C96D68@.microsoft.com...
> Hello
> I seem to have a re-occuring problem with tables.
> Every tiime i create a new table in my code (Table x = new Table();) it
> creates in the final code the browser gets the attribute 'border="0"'.(i
> prefer putting my styles in a seprate css file)
> Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
> nothing seems to work.even changing the Table.BorderWidth property creates
> a
> 'style="border-width:x"' and stucks me with the 'border="0"'.
> It happens even when i create classes derived from Table.
> Please help me,it's really annoying.
> Thank you.
> It's hard-coded in the table creation - unfortunetly. But I don't see why
> it'd be causing problems with your css decleration? if you do

> <table border="0" class="Blah"> and the Blah class defines a border, it
> ought to apply it reguarless of what the border says..

Not true, CSS properties are overriden by inline styles. Not very
helpful, I know.
Well, I'm willing to admit that i'm wrong...but...

I agree that external css properties are overriden by inline styles, but
border="0" isn't an inline style, it's an attribute decleration which ARE
overriden by any styles (inline or external).

so if you do:
<table border="0">
<tr><td>asdsa</td></tr>
</table
and you create a style in a css:

table
{
border:1px solid #000;
}

you WILL see the border

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/

"Flinky Wisty Pomm" <Pathogenix@.gmail.com> wrote in message
news:1139834577.520780.250200@.g47g2000cwa.googlegr oups.com...
>> It's hard-coded in the table creation - unfortunetly. But I don't see why
>> it'd be causing problems with your css decleration? if you do
>> <table border="0" class="Blah"> and the Blah class defines a border, it
>> ought to apply it reguarless of what the border says..
> Not true, CSS properties are overriden by inline styles. Not very
> helpful, I know.
Object withdrawn :)

Always happy to be proven wrong.

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?

Troubles with INSERT command

Hi, I am currently trying to INSERT selected rows from table Cart intotable Orders. Table Cart has columns Id_record(autonumber),Id_title(LongInt), Customer(text), Table Orders has the same columnsand also column Order_ID. When I delete this colums Order_ID and insertonly values from table cart like this, it works.
queryString = "INSERT INTO [Orders] SELECT * FROM [Cart] WHERE Cart.Customer = @dotnet.itags.org.user"
Dim dbCommand as OleDbCommand = new OleDbCommand(queryString, myConnection)
dbCommand.Parameters.Add(New OleDbParameter("@dotnet.itags.org.user", OleDbType.Char, 20))
dbCommand.Parameters("@dotnet.itags.org.user").Value = user.Identity.Name

Troubles begin, when I try to insert also that randomly generated number into my table Orders. I use this code...
Dim myConnection as OleDbConnection = new OleDbConnection(connectionString)
queryString = "INSERT INTO [Orders] SELECT *, @dotnet.itags.org.random as Order_ID FROM [Cart] WHERE Cart.Customer = @dotnet.itags.org.user"
Dim dbCommand as OleDbCommand = new OleDbCommand(queryString, myConnection)
dbCommand.Parameters.Add(New OleDbParameter("@dotnet.itags.org.user", OleDbType.Char, 20))
dbCommand.Parameters("@dotnet.itags.org.user").Value = user.Identity.Name
Randomize()
dbCommand.Parameters.Add(New OleDbParameter("@dotnet.itags.org.random", OleDbType.Integer, 20))
dbCommand.Parameters("@dotnet.itags.org.random").Value = ((Int32.MaxValue) * Rnd)
I always ger error "Duplicate output destination in Id_record" andhave no idea, how to fix it. Could pls somebody help me? Or could ugive me some link on some good INSERT tutorial?

If both the tables are not EXCTLY similar in columns you would get errors. So list out the column names xplicitly.
INSERT INTO col1, col2, col3 SELECT cart.col1, cart,col2, cart.col3 FROM cart WHERE Cart.Customer = @.user"

Exclude the identity column since you cannot manually insert into it.


Hm, so I changed my query into something like this, but now im gettingOverflow error. Does someone know what Overflow error means? Could bethis error caused bz the fact, that Id_record is autonumber in Carttable but I am trying to isnert it as integer in Orders table?

Dim myConnection as OleDbConnection = new OleDbConnection(connectionString)
queryString = "INSERT INTO [Orders] (Id_record,Id_title, Customer, Id_order) SELECT Id_record, Id_title, Customer,@.user FROM [Cart] WHERE Cart.Customer = @.user"
Dim dbCommand as OleDbCommand = new OleDbCommand(queryString, myConnection)
Randomize()
Dim Rand As Int32 = ((Int32.MaxValue) * Rnd)
dbCommand.Parameters.Add(New OleDbParameter("@.random", OleDbType.Integer, 20))
dbCommand.Parameters("@.random").Value = Rand
dbCommand.Parameters.Add(New OleDbParameter("@.user", OleDbType.Char, 20))
dbCommand.Parameters("@.user").Value = user.Identity.Name


queryString = "INSERT INTO [Orders] (Id_record, Id_title, Customer, Id_order) SELECT Id_record, Id_title, Customer, @.user FROM [Cart] WHERE Cart.Customer = @.user"

is Orders.Id_order column a autonumber column? if so you cant explicity insert into this column.
providing the sqldatatype(integer?) of Cart.Id_record is the same type as Orders.ID_record it shouldnt be a problem.
Well, Cart.ID_Record is the autonumber and Orders.ID_record is theinteger. I need to insert this autonumber into Orders.Id_record asinteger.
Orders.Id_order is normal Integer.
Edit: Hm, when i remove the last column from orders and try to insertjust first 3 columns, everything works fine. So the problem is either in the declaration of random variable or in the was it is placed in SQO query.


queryString = "INSERT INTO [Orders] (Id_record, Id_title, Customer, Id_order) SELECT Id_record, Id_title, Customer,@.user FROM [Cart] WHERE Cart.Customer = @.user"


whats with the @.user in the select list?
waht are you trying to do there with it?