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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Studio DataSets and DataSources

Status
Not open for further replies.

ProtocolPirate

Programmer
Nov 21, 2007
104
0
0
US
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.
 
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
 
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()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top