D
Durango2008
Hello everyone,
I have a very hairy problem that I need immediate help in. I have written a
simple web application which can upload and read in an Access mdb file,
retrieve its contents and populate a table in SQL server.
Here is where things get weird.
On my developement server it runs fine, no hiccups at all.
On my production server that the client uses it does not work.
All I get back is Server resources exceeded.
I looked this up on google and it explains that this can happen if too many
concurrent connection to an Access DB occur.
Now I am assuming that the server where things run fine allows more
connections to be left open than the one that the application breaks in.
Here is my code so you can get an idea of what I am doing.
I minimized the code for readability.
OleDbConnection accessConn =
new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + fileName);
OleDbDataReader OleDR_TblA = null, OleDR_TblB = null;
accessConn.Open();
OleDbCommand accessTblACmd = new OleDbCommand("select a, b, c from
[TblA] order by a", accessConn);
try
{
OleDR_TblA = accessTblACmd.ExecuteReader();
}
catch (Exception e)
{
msgStr = e.Message.ToString();
}
OleDbCommand accessTblBCmd = null;
while(OleDR_TblA.Read())
{
string aVal = OleDR_TblA.GetValue(0);
string bVal = OleDR_TblA.GetValue(1);
string cVal = OleDR_TblA.GetValue(2);
string d = a + "-" + b + "-" + c;
accessTblBCmd = new OleDbCommand("Select * from [TblB]
where id=" + d, accessConn);
try
{
OleDR_TblB = accessTblBCmd.ExecuteReader();
}
catch(){ Exception }
if (OleDR_TblB.HasRows)
{
OleDR_TblB.Read();
// Read the data
// Insert into SQL Server
}
}// end of while loop
// close all connections
OleDR_TblA.Close();
OleDR_TblB.Close();
accessConn.Close();
...etc.
As you can see I need to read one table to create a sql statement to read
the main data from a different table hence the way it's been coded.
Now again this works but not on the server that I need to put the web
application on.
I am a bit wet behind the ears with this stuff so excuse my ignorance, but I
am not sure what settings are different on the 2 servers that allows one to
work and not the other.
I am also curious on why the MS-Access file would create a lock if it is
only being read from and not written to.
I am not familiar with this stuff so I did not know how you can pass a
ReadOnly parameter to the connection.
Please give any criticism of my code, I know it's not good and I am happy to
hear any advice.
Thanks in advance,
Durnago.
I have a very hairy problem that I need immediate help in. I have written a
simple web application which can upload and read in an Access mdb file,
retrieve its contents and populate a table in SQL server.
Here is where things get weird.
On my developement server it runs fine, no hiccups at all.
On my production server that the client uses it does not work.
All I get back is Server resources exceeded.
I looked this up on google and it explains that this can happen if too many
concurrent connection to an Access DB occur.
Now I am assuming that the server where things run fine allows more
connections to be left open than the one that the application breaks in.
Here is my code so you can get an idea of what I am doing.
I minimized the code for readability.
OleDbConnection accessConn =
new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + fileName);
OleDbDataReader OleDR_TblA = null, OleDR_TblB = null;
accessConn.Open();
OleDbCommand accessTblACmd = new OleDbCommand("select a, b, c from
[TblA] order by a", accessConn);
try
{
OleDR_TblA = accessTblACmd.ExecuteReader();
}
catch (Exception e)
{
msgStr = e.Message.ToString();
}
OleDbCommand accessTblBCmd = null;
while(OleDR_TblA.Read())
{
string aVal = OleDR_TblA.GetValue(0);
string bVal = OleDR_TblA.GetValue(1);
string cVal = OleDR_TblA.GetValue(2);
string d = a + "-" + b + "-" + c;
accessTblBCmd = new OleDbCommand("Select * from [TblB]
where id=" + d, accessConn);
try
{
OleDR_TblB = accessTblBCmd.ExecuteReader();
}
catch(){ Exception }
if (OleDR_TblB.HasRows)
{
OleDR_TblB.Read();
// Read the data
// Insert into SQL Server
}
}// end of while loop
// close all connections
OleDR_TblA.Close();
OleDR_TblB.Close();
accessConn.Close();
...etc.
As you can see I need to read one table to create a sql statement to read
the main data from a different table hence the way it's been coded.
Now again this works but not on the server that I need to put the web
application on.
I am a bit wet behind the ears with this stuff so excuse my ignorance, but I
am not sure what settings are different on the 2 servers that allows one to
work and not the other.
I am also curious on why the MS-Access file would create a lock if it is
only being read from and not written to.
I am not familiar with this stuff so I did not know how you can pass a
ReadOnly parameter to the connection.
Please give any criticism of my code, I know it's not good and I am happy to
hear any advice.
Thanks in advance,
Durnago.