Now to get things started open your ms access 2003 and create a database name it "sample", if your version is 2007 or onwards don't forget to save as the database in 2003 format. To check if your database is in 2003 format the extension file should be ".mdb".
- After we create the database, open your visual studio and create a project. To create the project go to "file>new>project" choose visual basic as the language and the type should be Windows Form Application.
- For the name of the project type "sample" and for the location and solution leave it to its default and press OK.
- Now to start the coding double click on in the form1 and this should be in your screen now.
- First part of the code is we need to declare our import, click your mouse cursor before the Public Class Form1 and hit enter. After that type “Imports System.Data.OleDb ".
- Now that we declare our import next would be to declare is our oledbconnection. The purpose of oledbconnection is it acts as a switch to open or close the connection to our database. Click your mouse cursor below the Public Class Form1 then type "Dim con As New OleDbConnection".
- After declaring our import and oledbconnection we need now to specify our connection string and open our connection to check if it really connects to our database. Click inside between the private sub and end sub then type the following line of code.
"data source=c:\sample.mdb"
con.Open()
MessageBox.Show("Connected")
con.Close()
- If you notice in our connection string the provider we need to use since we are using MS Access 2003 is microsoft.jet.oledb.4.0 and for the data source is where our database is located. In this example I choose to place my database into my drive c so that it will be easier for me to locate the database. For further connection you can check this link connection strings.
- Below is the picture how the code should look like now.
hi,
ReplyDeleteI watched your video regarding listview in c#, Thanks for video, How can I pass listdata to textboxs for edit purpose .I mean When I double click a record in listview the same record is manipulated on textboxes for edit . ?