INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Studio DataSets and DataSources

Visual Studio DataSets and DataSources

(OP)
I can get VS2005 to work with my local copy of the database, but when I try to add a data source in VS2005 that is on the server it always bombs because of a failure in some stored procedure.

This is so maddening I'm ready to uninstall VS2005 and reinstall it. I just want to bind a table to my GridView.

If this can be done in code that would be better, I'm able to get a dataReader working with code, but for some reason I can't figure out how to use a programmatically created adapter with a GridView.

RE: Visual Studio DataSets and DataSources

This code works for me for getting data into the GridView:

CODE

        Dim dbConn As New PsqlConnection("ServerDSN=DEMODATA")
        dbConn.Open()
        Dim dbAdapter As New PsqlDataAdapter("select * FROM class", dbConn)
        Dim dataSet As New DataSet("MyDataSet")
        dbAdapter.Fill(dataSet, "class")
        DataGridView1.AutoGenerateColumns = True
        DataGridView1.DataMember = "class"
        DataGridView1.DataSource = dataSet

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Visual Studio DataSets and DataSources

(OP)
I forgot to mention that I need a binding source in the mix so that I can do filtering. This is what I finally got to work:

        Dim strCommand As String = "select Name, Id, Addr1, Addr2, City, State, Zip, UPin, Phone, PinNum, RefUPIN from Servloc"
        Dim strConnect As String = "Server=192.168.18.2;ServerDSN=live global data;Connection Timeout=150;Persist Security Info=True;Pooling=False;User ID=mike"
        Dim dbConn As New PsqlConnection(strConnect)
        dbConn.Open()
        Dim dbAdapter As New PsqlDataAdapter()
        dbAdapter.SelectCommand = New PsqlCommand(strCommand, dbConn)
        Dim dataSet As New DataSet("MyDataSet")
        dbAdapter.Fill(dataSet, "TableTest")
        m_bindSrc = New BindingSource()
        m_bindSrc.DataSource = dataSet.Tables(0)
        DataGridView1.DataSource = m_bindSrc
        DataGridView1.Sort(DataGridView1.Columns(0), Ascending)
        DataGridView1.AutoResizeColumns()

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close