Results 1 to 12 of 12

Thread: How to link grid control with the database using oledbconnection?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    16

    How to link grid control with the database using oledbconnection?

    i'm new in vb.net and i am having the problem as the topic stated.
    i don have any source code for the connection because i really donno how to do. so i need help from someone here and help me out for my problem.

    thank you.

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: How to link grid control with the database using oledbconnection?

    look at http://www.connectionstrings.com , has connections strings for all sorts of different types of providers

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to link grid control with the database using oledbconnection?

    Check out some of the tutorial links in my signature, as well as the 101 samples. You'll find plenty of ADO.NET stuff there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    16

    Re: How to link grid control with the database using oledbconnection?

    how you get a data from a database and place it in a text box.
    what i mean is a row of data from a table.

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: How to link grid control with the database using oledbconnection?

    requires several items using ADO.NET, as JM said... best to read up on it so you understand it first before you try anything... using the links in his sig...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    16

    Re: How to link grid control with the database using oledbconnection?

    Quote Originally Posted by gigemboy
    look at http://www.connectionstrings.com , has connections strings for all sorts of different types of providers

    Quote Originally Posted by jmcilhinney
    Check out some of the tutorial links in my signature, as well as the 101 samples. You'll find plenty of ADO.NET stuff there.

    Thanx ^^

  7. #7
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: How to link grid control with the database using oledbconnection?

    If you installed the documentation, there is a good intro article titled "Introduction to Data Access with ADO.NET", or you can search MSDN for that article as well...

    **EDIT

    For a more in depth article with full examples, check out the article "Accessing Data with ADO.NET"

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to link grid control with the database using oledbconnection?

    Quote Originally Posted by brian84
    how you get a data from a database and place it in a text box.
    what i mean is a row of data from a table.
    We're not trying to be unhelpful, but giving bits of code when you don't understand the subject is like teaching someone who doesn't know how to drive how to turn left: it's great for that specific circumstance but it doesn't really help much overall. Your thread title says you want to link a grid to a database. The last step of that process is to assign a DataTable object to the DataSource property of either a DataGrid or DataGridView, depending on which version of VB.NET you're using. If you don't know how to populate the DataTable in the first place then you should take our advice and do some reading.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    16

    Re: How to link grid control with the database using oledbconnection?

    The problem to connect the odbc with grid control had been solve but another problem occur again.

    after i connect the odbc and grid control together, i tried to view the table from the dataadapter's preview data and i works when i click to fill the dataset.
    but then i execute the code, the grid control do not show any data but oni the header and column name.

    wat is the problem here..??
    how can i show the data in the grid contorl..??
    * i only use a dataset without datatable and dataview

    *Problem solved
    Last edited by brian84; Nov 24th, 2005 at 10:28 PM.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    16

    Re: How to link grid control with the database using oledbconnection?

    i having another problem where i cannot update my data in the database/
    it is update using a datagrid
    i used the following code to update but it does not work.
    anybody can help what i should do before this code and after the code

    OleDbDataAdapter1.Update(DataSet1)

  11. #11
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: How to link grid control with the database using oledbconnection?

    You have to set the commandbuilder... it should automatically create the correct update commands when you call .update for general cases... sometimes this does not work if you are pulling data from multiple tables, etc...
    VB Code:
    1. Dim MyAdapter As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM " & strTable, strConn) 'just an example of an oledbdataadapter
    2. Dim MyCmdBuilder As New System.Data.OleDb.OleDbCommandBuilder(MyAdapter) 'creates the commandbuilder
    3. MyAdapter.Update(MyDataSet) 'update should now work now that the commandbuilder is set

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to link grid control with the database using oledbconnection?

    Just FYI, there is no such thing as a DataSet without a DataTable. A DateSet contains DataTables and DataRelations. It is the DataTable that contains the data, or more correctly that contains the DataRows that contain the data. If you are working with a single table of data and using a DataSet then you are adding an unnecessary layer of complexity. That's like creating an array that will only ever have one element.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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