Results 1 to 4 of 4

Thread: Using MDB for all all objects

  1. #1

    Thread Starter
    Hyperactive Member boku's Avatar
    Join Date
    Dec 2004
    Posts
    386

    Using MDB for all all objects

    Hi guys,

    I am just wondering how you would do it basically?

    The plan is to use a database just a MDB one, which holds all text fields for all the objects in my application.

    For example (real dodgy example)

    Label1.text = "Select NewText from Table where [ID] =" & Label1.Name & " and [ENABLED]=1"

    I want this to go for every single control in my application, which basically would allow any client to completely customize text fields in the app.

    How would you do it?

    Currently I'm using this so far to access the Data. But before I continue I want to see what you guys would do?

    Code:
    Imports System.Data.OleDb
    
    Public Class Form1
    
        Dim objconnection As New OleDbConnection
        Dim conn As OleDbConnection
        Dim cmd As New OleDbCommand
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database.mdb;")
    
            Dim cmd As New OleDbCommand("select * from Table", conn)
    
    End Sub
    
    End Class
    -BoKu-

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using MDB for all all objects

    Hey,

    What you have there is certainly a valid method for connecting to the database and retrieving data. If you are unsure about some of the concepts, have a look at this thread:

    http://www.vbforums.com/showthread.php?t=469872

    And for Access specific information have a look at the link in my signature.

    How you go about binding the information to your UI controls is completely up to you, and I guess it depends on what exactly you are showing. For instance, you may return a DataSet from the Database and you bind this directly to a DataGridView, or you may decide to use a BindingSource in conjunction with a BindNavigator to allow traversal of the records in the dataset.

    Firstly though, I would familiarize yourself with the concepts of ADO.Net and then worry about how you are going to display it.

    Gary

  3. #3

    Thread Starter
    Hyperactive Member boku's Avatar
    Join Date
    Dec 2004
    Posts
    386

    Re: Using MDB for all all objects

    Thanks Gep13 those links are excellent, I think they'll provide me with all the info i'd ever require.

    However, how would you set the text for all form controls?

    Load the database into a gridview and then set the items from there or just set all from the database directly?
    -BoKu-

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Using MDB for all all objects

    Hey,

    There are a number of ways you can do this, and it depends on how you want to retrieve your data.

    Assuming that you have Visual Studio Standard or above, you could for instance create a data source within your application and construct a strongly typed dataset. From there it is possible to drag a table onto the form's surface which will then automatically create the textbox's that represent each field within the database.

    Have a look at this walkthrough which talks you through doing exactly that:

    http://msdn.microsoft.com/en-us/libr...az(VS.80).aspx

    Of course, if you need more control over your application you can manually set the Text property of each of the TextBoxes based on the information that you pull back from your query. However, it all depends on the nature of the query and the architecture that you wish to adopt for your application.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width