C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




how to connect VB with Ms acess


Posted Date: 14 Aug 2008      Total Responses: 5

Posted By: Seetha lakshmi       Member Level: Silver     Points: 1



I want to connect the database
could u pls tel me the steps to connect?





Responses

Author: karthik gattu    14 Aug 2008Member Level: SilverRating:     Points: 3

"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; User Id=admin; Password="
And remaining steps will be similar like sql



Author: Danasegarane.A    14 Aug 2008Member Level: DiamondRating:     Points: 2

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=3510&lngWId=1


Download the project and run

Hope this helps

Dana

Thanks and Regards,
Danasegarane Arunachalam



Author: Danasegarane.A    14 Aug 2008Member Level: DiamondRating:     Points: 6

Alternativly you can run this query in IE to get more
source codes

http://www.pscode.com/vb/scripts/BrowseCategoryOrSearchResults.asp?lngWId=1&?lngWId=1&grpCategories=&txtMaxNumberOfEntriesPerPage=10&optSort=Alphabetical&chkThoroughSearch=&blnTopCode=False&blnNewestCode=False&blnAuthorSearch=False&lngAuthorId=&strAuthorName=&blnResetAllVariables=&blnEditCode=False&mblnIsSuperAdminAccessOn=False&intFirstRecordOnPage=1&intLastRecordOnPage=10&intMaxNumberOfEntriesPerPage=10&intLastRecordInRecordset=177&chkCodeTypeZip=&chkCodeDifficulty=&chkCodeTypeText=&chkCodeTypeArticle=&chkCode3rdPartyReview=&txtCriteria=connect+to+access



Hope this helps

Dana

Thanks and Regards,
Danasegarane Arunachalam



Author: venkatesan    14 Aug 2008Member Level: DiamondRating:     Points: 4

Dim conn as New ADODB.Connection
Dim rs as New ADODB.Recordset
Dim sqlPhrase as string

cn.open "<supply here the connection string given in the adodb>"
sqlPrase = "<put your sql command here>"
rs.cursortype = adopendynamic
rs.cursorlocation = aduseclient
rs.locktype = adlockoptimistic
rs.open sqlPhrase,conn
'try to use flexgrid or data grid to show the results
conn.close
rs.close



Wish u a Very Happy New Year
Regards,
M.Venkatesan.

Please remember to Rate “Excellent or Good or Poor”



Author: Vijayaragavan.R    26 Aug 2008Member Level: BronzeRating:     Points: 6

To connect vb6.0 and MS access, I will make an example of connecting them using ADODB.

Dim sConn as string 'for the connection string

'now we declare the ADODB connection

'to be able to show this NEW ADODB.Connection line, you must do the following:

1. in the toolbox, you must add a component.
2. in the component box, find the Microsoft ActiveX ADO connection something like that.
3. then when this is done, drag the component into your form and then delete it
4. this way you may be able to have the NEW ADODB line in your intellisense

now lets proceed to connecting you db and vb6.0

Dim db as New ADODB.Connection
dim rs as new ADODB.Recordset
dim sPath as string ' here we put the path of your database
dim sSQL as string 'your SQL Statement

'like for example your vb application is on C:\MyVB
' and within that your DB is under another folder called DB
' we must get the path C:\MyVB\DB\yourdbname.mdb
' we shall be using app.path for getting the path of your application that is the C:\MyVB
' then we must concatenate the folder and the name of your database.

sPath = app.path & "\DB\yourdbname.mdb;"

'initialize the connection string

sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath

sSQL = "SELECT * FROM yourtablename"

now let us proceed to the main part

Private Sub frmMain_Load()
db.ConnectionString = sConn
db.Open

with rs
.activeconnection = db
.locktype = adlockoptimistic
.cursortype = adopenkeyset
.open sSQL

' now let us loop through your records and show it to your label
' for example your table has two fields, the field called name and description

do while not .eof
label1.caption = .fields("name").value & vbCrLf & .fields("description").value & vbCrLf

.movenext
loop

'let close the rs connection
rs.close
end with
set rs = nothing
db.close
set db = nothing
End Sub



Post Reply
You must Sign In to post a response.
Next : hello venkat this is the code i have given.. pls check out
Previous : Popup vb6
Return to Discussion Forum
Post New Message
Category: Visual Studio

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use