473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

asking about vb programming

hi sir i am the fresher in programming in vb so i want to know that how to connect the database ms access in vb kindly inform me ?
Jan 31 '08 #1
2 882
daniel aristidou
491 256MB
how to connect the database ms access in vb kindly inform me ?
Ok....This greatly depends on which version of vb you are using.....
If you could please post which version of vb you are using....we can give you a more specific answer..
Jan 31 '08 #2
jamesd0142
469 256MB
This works for vb2005, and i belive vb.net also.

add this above you class declaration:
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2.  
THis code allows you to update tables and records etc:
Just change commandtext and source etc:
Expand|Select|Wrap|Line Numbers
  1. Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Users\Users.mdb"
  2.             Dim oConn As New System.Data.OleDb.OleDbConnection(StrConn)
  3.             Dim con As New System.Data.OleDb.OleDbCommand
  4.             con.Connection = oConn
  5.             con.CommandType = CommandType.Text
  6.             con.CommandText = "insert into tblusers (FirstName,LastName,Login,[Password], Passwordchanged) values (" & "'" & txtFirstName.Text & "'," & "'" & txtLastName.Text & "'," & "'" & txtLogin.Text & "'," & "'" & txtPassword.Text & "'," & "'" & strdate & "')"
  7.             'add("insert into tblusers (FirstName,LastName,Login,[Password], Passwordchanged) values (" & "'" & "c" & "'," & "'" & "c" & "'," & "'" & "c" & "'," & "'" & "c" & "'," & "'" & strdate & "')")
  8.             '"Update TBLUsers set [login] = " & "'" & "NEW" & "'" & " where [FirstName] = " & "'" & "ab" & "'"
  9.             oConn.Open()
  10.             con.ExecuteNonQuery()
  11.             oConn.Close()
  12.  
This allows you to query the table
Expand|Select|Wrap|Line Numbers
  1. Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Users\Users.mdb"
  2.             Dim oConn As New System.Data.OleDb.OleDbConnection(StrConn)
  3.             Dim da As System.Data.OleDb.OleDbDataAdapter
  4.             Dim oDS As New System.Data.DataSet
  5.             Dim strSQL As String = "Select * From tblUsers"
  6.             da = New OleDbDataAdapter(strSQL, oConn)
  7.             da.Fill(oDS, "Table1")
  8.             DGV1.DataSource = oDS.Tables("Table1").DefaultView
  9.             DGV1.Refresh()
  10.             da = Nothing
  11.             oDS = Nothing
  12.             oConn = Nothing
  13.  
Cheers James
Jan 31 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

258
by: Terry Andersen | last post by:
If I have: struct one_{ unsigned int one_1; unsigned short one_2; unsigned short one_3; }; struct two_{ unsigned int two_1;
17
by: I_got_questions? | last post by:
I just started c programming. I want to migrate to c++. I know a little bit about class/inheritance. I am asking for good books to read. Elementary will be good. Thanks for any comments
4
by: Sumit | last post by:
Hello! I I am new to this group and a beginner in C programming. I want to know that now should I give more importance in learning programming fundamentals and program solving or on good...
4
by: Lumpy | last post by:
Hello All, I have a question that maybe someone on here could answer. I have built websites and done other misc programming work for myself for the last couple of years. Mostly just smaller scale...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.