473,432 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

Problems to access data and saving date/time to database

I created a ASP.NET page using C# and I'm using two components to access a
MS-Access database, which are:

- oleDbConnection
- oleDataAdapter

The MS-Access database is in the correct directory (IIS has permission to
read/write) and everything seems ok, but IIS says that it can't open the
file because there is someone else using it exclusively (impossible, I'm
using a stand alone computer and I closed everything) or I need permission
to open the file, which is strange too.

On the .net framework configuration, I set all codes in my computer to have
"full trust", is this the correct way of doing it? Or a should actually
register the dll file on it? How is this supposed to be done?

I also would like to know if the way I'm trying to save date/time to the
database is correct.

--------- code ---------

protected System.Web.UI.WebControls.Label Label1;

protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator1;

protected System.Web.UI.WebControls.TextBox nome;

protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator2;

protected System.Web.UI.WebControls.TextBox msg;

protected System.Web.UI.WebControls.Label Label2;

protected System.Data.OleDb.OleDbConnection oleDbConnection1;

protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;

protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;

protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1;

protected System.Web.UI.WebControls.Label Erro;

protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (IsPostBack)
{
try {
oleDbConnection1.Open();

oleDbDataAdapter1.InsertCommand.CommandText =
"INSERT INTO [msg log] "+
"(hora, msg, nome) "+
"VALUES ("+
"'"+DateTime.Now.ToString()+"', "+
"'"+nome.Text+"', "+
"'"+msg.Text+"')";

oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();

oleDbConnection1.Close();

nome.Text = "";
msg.Text = "";

Erro.Visible = false;
}
catch (System.Data.OleDb.OleDbException exception)
{
Erro.Visible = true;
Erro.Text = "Erro no servidor: " +
exception.ToString();
}
}
}

--------- code ---------

Thanks.
Nov 19 '05 #1
1 1712
Hi Ruy Castelli,

The problem arises , since the user you are using for running your
application don't have permission to open the access file.
Goto the folder location which contains the Access File.

Select the propertis for that folder and goto the security tab. Make sure
that ASPNET user is added in the list and has full permisson. Moreover if you
are using a widnows based authentication ...then include that user account
also in the list with necessary permission.

Just make sure the same security settings for the mdb file too.

Cheers,

Jerome. M

"Ruy Castelli" wrote:
I created a ASP.NET page using C# and I'm using two components to access a
MS-Access database, which are:

- oleDbConnection
- oleDataAdapter

The MS-Access database is in the correct directory (IIS has permission to
read/write) and everything seems ok, but IIS says that it can't open the
file because there is someone else using it exclusively (impossible, I'm
using a stand alone computer and I closed everything) or I need permission
to open the file, which is strange too.

On the .net framework configuration, I set all codes in my computer to have
"full trust", is this the correct way of doing it? Or a should actually
register the dll file on it? How is this supposed to be done?

I also would like to know if the way I'm trying to save date/time to the
database is correct.

--------- code ---------

protected System.Web.UI.WebControls.Label Label1;

protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator1;

protected System.Web.UI.WebControls.TextBox nome;

protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator2;

protected System.Web.UI.WebControls.TextBox msg;

protected System.Web.UI.WebControls.Label Label2;

protected System.Data.OleDb.OleDbConnection oleDbConnection1;

protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;

protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;

protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1;

protected System.Web.UI.WebControls.Label Erro;

protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (IsPostBack)
{
try {
oleDbConnection1.Open();

oleDbDataAdapter1.InsertCommand.CommandText =
"INSERT INTO [msg log] "+
"(hora, msg, nome) "+
"VALUES ("+
"'"+DateTime.Now.ToString()+"', "+
"'"+nome.Text+"', "+
"'"+msg.Text+"')";

oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();

oleDbConnection1.Close();

nome.Text = "";
msg.Text = "";

Erro.Visible = false;
}
catch (System.Data.OleDb.OleDbException exception)
{
Erro.Visible = true;
Erro.Text = "Erro no servidor: " +
exception.ToString();
}
}
}

--------- code ---------

Thanks.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
2
by: Atreju | last post by:
I apologize in advance for the x-post, but I am really not sure where this would best be addressed. I am designing a database in MSAccess for which I want to make the front-end in VB. I have...
2
by: Joseph Macari | last post by:
I recently installed Office2003 on my computer. I had imported (not linked) a couple of tables from an Access 2000mdb into an Access 2003mdb. I had composed various queries and forms with these...
1
by: Rolan | last post by:
Perhaps someone has experience these two problems and if there are any fixes or workarounds, I sure would like to know. I'm using Access 97. When exporting data in html from one database that...
4
by: Ruy Castelli | last post by:
I created a ASP.NET page using C# and I'm using two components to access a MS-Access database, which are: - oleDbConnection - oleDataAdapter The MS-Access database is in the correct...
17
by: Woody Splawn | last post by:
I am finding that time after time I have instances where I need to access information in a variable that is public. At the same time, the books I read say that one should not use public variables...
18
JamesDC
by: JamesDC | last post by:
Hi, So I'm working with an Access 2002 database for waste managemnt. The person in my role before my put together the program before he left and now I'm in charge of it. After updating a few...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.