Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Databases

Status
Not open for further replies.

ScudDE

Technical User
Aug 30, 2004
19
AU
Hi guys;
how are you?

Well here's somthing i havnt done in a while. Program in VB.NET and something i have hardly done, Using Databases. Could someone run me through on the steps to creating a database in VB.Net using Access or something. I just want to be able to do simple things like search a database, pull data out..

Thanks in advance,
Scud

Scud
Globaly Local Admin
Please join Globaly Local for FREE
 
You will find several examples of this when you do a search.

and there are more then one faq on the subject
faq796-3888
faq796-3727

if you have a more specific question, please feel free to come back.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Im still not clear, how do i make attach a database created in access to my vb.net program and then be able to search cells in the database

Scud
 
LOL... We're here. We all break for dinner after work. :)

There are several ways to do this.. the easiest (IMHO) is to create a new Data Connection inside the Server Explorer panel on the left.

1. Right Click Data Connections and choose Add Connection
2. Click on Provider Tab and choose the Microsoft Jet 4.0 Provider
3. Click Next :)
4. Click on the elipses and browse to your Access .MDB file.
5. Click OK

Now, drag that new connection to your form

Next Go back to the ToolBox and goto the Data group. Drag and drop the OleDBDataAdapter and let the wizard walk you through selecting your tables/rows to pull back.

:)

--
James
 
This is programatically:
Create a AccesDatabase with the name "TEST" and place it on C:\
Enter values in FIELD1
Create a Form and add a ComboBox

Code:
Imports System.Data.OleDb

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ConnectionString As String
        Dim DbConnection As OleDbConnection

        Dim DbCommandFIELD1 As OleDbCommand
        Dim DbDataReaderFIELD1 As OleDbDataReader

        Try
            ConnectionString = _
                "Provider = Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source = C:\Test.mdb; Mode = Read;" & _
                "Persist Security Info = False"

            DbConnection = New OleDbConnection(ConnectionString)
            DbConnection.Open()

            DbCommandPlaats = New OleDbCommand("SELECT DISTINCT FIELD1 FROM TEST", DbConnection)
            DbDataReaderPlaats = DbCommandPlaats.ExecuteReader

            Do While DbDataReaderPlaats.Read
                ComboBox1.Items.Add(DbDataReaderPlaats("FIELD1").ToString)
            Loop
            DbDataReaderPlaats.Close()
 
        Catch ex As OleDbException
            Dim i As Integer
            For i = 0 To ex.Errors.Count - 1
                MessageBox.Show(ex.Errors(i).Message)
            Next
        End Try
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top