[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

how to connect asp.net with MS-access and also how to pass data t

Jack

9/14/2006 1:03:00 AM

hI,

Anyone here know how to connect asp.net with MS-access and also how to pass
data to a table?

The following is the code which I have but unfortunately its not working..
Public Connectionstring As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
C:\Inetpub\wwwroot\Dee\ASPdotnet\currt.mdb;Persist Security Info=False;"
Public con As New OleDbConnection(Connectionstring)


Dim strSelect As String
strSelect = "Insert Into UserDetails1 (Username) Values
(@DetailsUser)"
Dim cmd As New OleDbCommand(strSelect, con)
Dim added As Integer
cmd.Parameters.Add("@DetailsUser", txtUserDetails.Text)

Try
con.Open()
cmd.ExecuteNonQuery()
Response.Write("Updated Successfully!<p> </p><p> </p><p> </p>")

con.Close()
Response.Write("Updated Successfully!<p> </p><p> </p><p> </p>")
Catch
con.Close()
End Try



Thanks in advance
Jack

1 Answer

Jim Hughes

9/15/2006 3:17:00 PM

0

By default, the account used to run ASP.net web pages will not have
read/write access to the files/folders under wwwroot.

You will need to grant that account read/write access to the folder where
the MDB file resides so that the Jet driver can create the ldb locking file
and update the mdb file.

I would encourage you to look into using SQL Express or SQL Server. Access
doesn''t work well in a web server app. (slow, locking problems, scalability,
permissions etc).

Also be sure that you wrap any reserved words in [ ]

con.Close should be in a Finally block, not the Catch.

You are also hiding any Exception, therefore you don''t know what the problem
is.

use
Try
Catch Ex as Exception
'' at least during debugging, don''t really want to send detailed errors to
client!
Response.Write(ex.Message)
Finally
End Try

"Jack" <Jack@discussions.microsoft.com> wrote in message
news:C90047E5-55A3-4753-8266-FA60107C4064@microsoft.com...
> hI,
>
> Anyone here know how to connect asp.net with MS-access and also how to
> pass
> data to a table?
>
> The following is the code which I have but unfortunately its not working..
> Public Connectionstring As String =
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
> C:\Inetpub\wwwroot\Dee\ASPdotnet\currt.mdb;Persist Security Info=False;"
> Public con As New OleDbConnection(Connectionstring)
>
>
> Dim strSelect As String
> strSelect = "Insert Into UserDetails1 (Username) Values
> (@DetailsUser)"
> Dim cmd As New OleDbCommand(strSelect, con)
> Dim added As Integer
> cmd.Parameters.Add("@DetailsUser", txtUserDetails.Text)
>
> Try
> con.Open()
> cmd.ExecuteNonQuery()
> Response.Write("Updated Successfully!<p> </p><p> </p><p> </p>")
>
> con.Close()
> Response.Write("Updated Successfully!<p> </p><p> </p><p> </p>")
> Catch
> con.Close()
> End Try
>
>
>
> Thanks in advance
> Jack
>