954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to connect ms access to asp.net

hye,

i need help about asp.net..i new in this language. so i don't know how to connect database from ms access to asp.net and submit button.

the situation : when the user click on submit button, the data that they fill in will insert in database.

izzatikhalid
Newbie Poster
4 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This forum section is for Classic ASP.

Please take the elevator to the next floor for ASP.NET

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

first add a namespace to your form for vb.net

imports System.Data.OledDb
//then on button click event write this code
dim con as new OleDbConnection
con.ConectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;""
Con.open()\\access.mdb is my databasename
dim str as string
try
str="INsert into [table] values ('hi')"
dim cmd=new sqlCommand(str,con)
cmd.ExequteNonquery
 Msgbox ("Recored inserted")
Catch ex as Exception
Mesgbox (ex.Message)
Finally
cmd=nothing
con.close
end try
pritesh2010
Posting Whiz in Training
261 posts since Mar 2010
Reputation Points: 40
Solved Threads: 46
 

just add this coding??is it right?

should i open a file in ms access,

izzatikhalid
Newbie Poster
4 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

yes this code will work..

if you have database at right place..
and database correctly desined

before that go for http://asp.net/learn/

there are plenty of video tutorials..
go through them

dnanetwork
Practically a Master Poster
Banned
633 posts since May 2008
Reputation Points: 28
Solved Threads: 106
 

To connect MS access database in asp.net put following code in your project web.config file <connectionstring> tag.

<connectionStrings> <add name="myconnection"

connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source= |DataDirectory|db1.mdb"
providerName="System.Data.OleDb"></add>
</connectionStrings>
searchec
Newbie Poster
12 posts since Aug 2010
Reputation Points: 8
Solved Threads: 1
 

hi izzatikhalid,

here is the code:

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\emp.mdb;")
Dim str="insert into emp values('"& txtName &"','"& txtPassword &"','"& txtAddress &"')"
con.Open()
Dim cmd = New OleDbCommand(str,con)
cmd.executeNonQuery()
con.Close()
End Sub

1. In above example you can put your fielsd name in txtname, txtpassword etc..
2. just change the Data Source="your ms acces table path"
Do write if have prob
Happy coding

tarwara
Newbie Poster
8 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

okkkkkkkkkkkkkkkkkkkkkkk

To connect MS access database in asp.net put following code in your project web.config file <connectionstring> tag.

<connectionStrings> <add name="myconnection"

connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source= |DataDirectory|db1.mdb"
providerName="System.Data.OleDb"></add>
</connectionStrings>
dbeura
Newbie Poster
7 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: