473,322 Members | 1,846 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,322 software developers and data experts.

linking vb to access databases

3
i created a simple form in vb which has id and name as the fields and i want to link to my table in access,please help me with the code.TIA
Mar 22 '08 #1
2 1052
jg007
283 100+
There will probably be much better answers than this but this is something I used for a project I was trying so might help you to get started at least :)

it links to c:\db1.mbd and pulls user names from a table called users with 2 columns, with the user name in the second column

Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data
  3. Public Class Form1
  4.  
  5.     Dim con As New OleDb.OleDbConnection
  6.     Dim n as integer
  7.     Dim ds As New DataSet
  8.     Dim tableselect As New Data.DataTable
  9.     Dim da As OleDb.OleDbDataAdapter
  10.     Dim sql As String
  11.  
  12.  
  13.  
  14.  
  15.  
  16.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.         con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\db1.mdb"
  25.         con.Open()
  26.         sql = "SELECT * FROM Users"
  27.         da = New OleDb.OleDbDataAdapter(sql, con)
  28.         da.Fill(ds, "Users")
  29.         tableselect = ds.Tables("Users")
  30.         Dim comb(tableselect.Rows.Count) As String
  31.         For n = 0 To tableselect.Rows.Count - 1
  32.  
  33.             comb(n) = New String(ds.Tables("Users").Rows(n).Item(1))
  34.  
  35.         Next n
  36.  
  37.         For n = 0 To tableselect.Rows.Count - 1
  38.             ComboBox1.Items.Add(comb(n))
  39.         Next
  40.  
  41.         con.Close()
  42.  
  43.  
  44.     End Sub
  45.  
  46.  
  47. End Class
  48.  
  49.  
Mar 23 '08 #2
lotus18
866 512MB
Attempt to achieve it by yourself. Paste some of your codes here that you may find difficult. Please be specific, what version of vb are you using, the backend, etc, and please observe posting guidelines.

Rey Sean
Mar 23 '08 #3

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

Similar topics

3
by: John South | last post by:
I have an Access 2000 front end that I wish to work with a SQL Server 2000 database by means of Linked tables. Do I have to use an ODBC connection to SQL Server? It seems to be the only option...
3
by: Ken | last post by:
I have a win 2000 database of autographs and scanned photos. They are in the SAME directory. In the table, my "ImagePath" text field shows JUST the image name (i.e. "blank.jpg"). I have an image...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
by: TheTamdino | last post by:
One of the things that is common between most genealogy databases is that they will have one screen were you log all the information for a given person and then (maybe) have a link to a source...
5
by: chrisse_2 | last post by:
Hi, All the records in my database will contain at least one picture. At the moment all the images are part of the database as ole objects although the database is way to big and there is only...
4
by: Supa Hoopsa | last post by:
I am in the process of rewriting an MS Access application (access front end with SQL 2k database) in VB.NET and one of the things I would like to do is link in to the compiled Access ADE so that I...
1
by: lochmant | last post by:
I have a series of about 10 test databases with about 34 linked table each. I need to create an Access 2003 database front end for each of these. I am currently trying to write a script that will...
7
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro...
1
by: agarwasa2008 | last post by:
Hi, I have a perfect file called "Products.xls" that I link to my MS Access 2003 database and everytthing looks good in that file. When I view the same file after linking in my database the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.