MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet
Author Message
Jack



Joined: 08 Aug 2007
Posts: 6

PostPosted: Wed Sep 13, 2006 10:03 pm    Post subject: how to connect asp.net with MS-access and also how to pass d Reply with quote

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! ")

con.Close()
Response.Write("Updated Successfully! ")
Catch
con.Close()
End Try



Thanks in advance
Jack

Archived from group: microsoft>public>dotnet>framework>odbcnet
Back to top
View user's profile Send private message
Jim Hughes



Joined: 08 Aug 2007
Posts: 3

PostPosted: Fri Sep 15, 2006 12:17 pm    Post subject: Re: how to connect asp.net with MS-access and also how to pa Reply with quote

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" wrote in message @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! ")
>
> con.Close()
> Response.Write("Updated Successfully! ")
> Catch
> con.Close()
> End Try
>
>
>
> Thanks in advance
> Jack
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Cannot connect to remote data Hello all, I have IIS 5.1 on an XP pro computer running an ASP.NET app that uses an ODBC DSN connection. I am using the Microsoft dBase driver. The data is on another server (Windows 2003). I can access the data if it and IIS are running on the same compu

Connect as SYSdba ORacle How does one create as system DNS that can connect as sysdba in Oracle. In TNS Service name I put the service name and in the user I have tried sys as sysdba 'sys as sysdba' "sys as sysdba" but nothing works. Any direction is appreciated it. Gene

Connect to AS400 VS2003 vs VS2005 Hi. I have recently upgrade from VS2003 to VS2005. In VS2003 I could connect to the AS400 and the tables folder would contain the correct amount table name for the selected libraries. When I connect in VS2005 I am getting 21000 table names and many are du

How to connect to lotus domino database ? Hy all. Is there a way to connect to a lotyus notes database (.nsf) in vb.net with the standard OleDBClient or ODBCClient classes ? Do you have an example ? The only way that I have found is to buy the Proposion N2N product. Thank you. Roby

Hiding the password and UID in connect strings Hi I'm using ASP.NET and VB.Net to connect to a MySQL database. My connection string is written within the VB.Net code on a button event, so it's not easily accessed by people viewing the HTML source... However, I don't feel comfortable with hardcoding my
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group