473,433 Members | 2,051 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,433 software developers and data experts.

ADO.NET 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
write. 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.

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 16 '05 #1
4 2458
Ruy

What you mean with MS Access database is in the correct directory.

Are you sure that the ASPNET user has all rights to use it.

Mostly is that this problem.

I hope this helps

Cor
Nov 16 '05 #2
Hello,

thanks for answering, but I still couldn't access the file.

- MS Access is in a directory with permission to read and write (on IIS),
that's what a mean my "right" directory.

- 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?

Thanks a lot.

"Cor Ligthert" <no************@planet.nl> escreveu na mensagem
news:uD**************@TK2MSFTNGP09.phx.gbl...
Ruy

What you mean with MS Access database is in the correct directory.

Are you sure that the ASPNET user has all rights to use it.

Mostly is that this problem.

I hope this helps

Cor

Nov 16 '05 #3
Ruy,

My problem is that when I have solved this I forget it again.

However it is so often asked that in my opinion in the ASPNET newsgroup you
get direct all answers.

You can search it as well on the exact message when you get that is in
English, than you will find it for sure. (Probably you don't get this exact
message in English and than I know that searching for this is a hell).

Maybe you can ask it in the ASPNET newsgroup, because it is one of the most
asked problems in my opinion. (However see the rest of my message first
before you click :-) )

Aspnet
news://msnews.microsoft.com/microsof...amework.aspnet

Web interface:
http://communities2.microsoft.com/co...amework.aspnet

I see I missed your second question.

Better are the commandparameters to use. Than you can tell the format of the
datetime and use that directly by setting the value to the datetime you
want. Than you are direct rid from all culture or whatever problem like
that.

http://msdn.microsoft.com/library/de...eterstopic.asp

For that is as well a better newsgroup (not to send you away, just to make
you attent on that ).

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

I hope this helps

Cor

Nov 16 '05 #4
Thanks, I'll try that.

"Cor Ligthert" <no************@planet.nl> escreveu na mensagem
news:%2****************@TK2MSFTNGP09.phx.gbl...
Ruy,

My problem is that when I have solved this I forget it again.

However it is so often asked that in my opinion in the ASPNET newsgroup
you get direct all answers.

You can search it as well on the exact message when you get that is in
English, than you will find it for sure. (Probably you don't get this
exact message in English and than I know that searching for this is a
hell).

Maybe you can ask it in the ASPNET newsgroup, because it is one of the
most asked problems in my opinion. (However see the rest of my message
first before you click :-) )

Aspnet
news://msnews.microsoft.com/microsof...amework.aspnet

Web interface:
http://communities2.microsoft.com/co...amework.aspnet

I see I missed your second question.

Better are the commandparameters to use. Than you can tell the format of
the datetime and use that directly by setting the value to the datetime
you want. Than you are direct rid from all culture or whatever problem
like that.

http://msdn.microsoft.com/library/de...eterstopic.asp

For that is as well a better newsgroup (not to send you away, just to make
you attent on that ).

Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

I hope this helps

Cor

Nov 16 '05 #5

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...
1
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 directory...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.