Hello
I want to connect asp.net with ms access but I am not able to do it. Can anyone tell me how can i do it?
Hello
I want to connect asp.net with ms access but I am not able to do it. Can anyone tell me how can i do it?
if you wants to connect asp.net with access to write 0above coding:
imports system.data.oledb
dim cn as new oldbconnection("connectionstring")
dim cmd as new oledbcommand("select * from table name")
cmd.executereader
To connect asp.net with access, do following steps :
1. Import the follwing namespaces at the top of the page.
=> imports system.data
=> imports system.data.oledb
2.The write the following code at the page load event
page_load()
Dim cn as new oledbconnection("connectionstring")
dim adp as new oledbdataadapter("select * from table",cn)
dim ds as new dataset
adp.fill(ds)
3. and show it in the required control
1. Replace username with your Brinkster hosting account username.
2. Replace C:\sites\single??\username\database\YourDB.mdb with the path to your web space.
3. Replace password with the password for the email account used above.
4. Please log into your account, select the web site settings, and use the absolute path to your file structure.
<%
Dim sPath as String = "C:\sites\single??\username\database\YourDB.md b"
Dim strConnection As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & sPath & ""
Dim sSQL As String = "Select * from tablename"
Dim objConnection As Data.OleDb.OleDbConnection = New Data.OleDb.OleDbConnection(strConnection)
Dim objCommandAuction1 As Data.OleDb.OleDbCommand = New Data.OleDb.OleDbCommand(sSQL, objConnection)
Dim oDr As Data.IDataReader
Try
objConnection.Open()
oDr = objCommandAuction1.ExecuteReader()
Do While oDr.Read
'Write information from database here
Loop
oDr.Close()
Catch ex As Exception
Response.Write(ex.Message)
End Try
objConnection.Close()
%>
thanks for giving such a nice answer..
its a very helpful posting you have did it...
and i have tried it to search on Link1
but not get any satisfactory...
thanks......
.......<THANKS>.......
![]()
It is easy.
First make connection object then pass connection string for MS access to connection object.....
using system.data.oledb
than take bind source and put one design forum
in their select property source select and select MS access than select data base then next
and copy the connection string ok
use it in coding page
This process is same as sql server, only difference is use oledb. As explained above will work for sure.
Bookmarks