Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem with dataset

Posted on 2006-07-17
7
Medium Priority
?
186 Views
Last Modified: 2012-03-15
Hello

I am trying to do something similar to this code:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21156889.html?query=dataset&topics=866

It doesnt seem to be working for me.

I get an error saying object reference not set to an instance of an object.

When I add the new keyword to the dim, it shows rows.count as 0 when there is 2 rows in the table.

Any ideas?

Bryan
0
Comment
Question by:bryanford
  • 4
  • 2
7 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 17126960
Can you post all of your code?
0
 
LVL 1

Author Comment

by:bryanford
ID: 17126995
Imports System.Windows.Forms

Public Class testform

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim ds as smDataSet

For x as Integer = 0 to ds.Tables("tblServer").Rows.Count - 1
        Messagebox.Show(ds.Tables("tblServer").Rows(x).Item("ServerID"))
Next

End Sub

End Class
0
 
LVL 10

Expert Comment

by:bchoor
ID: 17127000
Imports system.data
Imports system.data.sqlclient

Dim ds as new dataset
Dim da as new sqlDataAdapter("SELECT * FROM TABLE", ConnectionString)

da.Fill(ds, "YourTable")

then you will be able to pull the records

HTH
~BC
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:bryanford
ID: 17127031
bchoor,

Do i still need to do that even though I have all the tables and connection strings in a XSD DataSet designer?
0
 
LVL 10

Accepted Solution

by:
bchoor earned 1000 total points
ID: 17127049
kind of

assume your dataset namespace in your designer is MyDataSet
and the datatable classes are DSMyTable
and the dataAdapter is DAMyTableAdapter

Then
Dim ds As New MyDataSet.DSMyTableDataTable
Dim da As New MyDataSetTableAdapters.DSMYTableAdapter

da.Fill(ds)

When you type the code in, intellisense will help you figure out which ones

Basically, the concept is that you need to create an adapter that will communicate with the database. Then, it will fill a table (or datatable) within a dataset. To update it goes the same way, the datatable assesses the chagnes which get pushed to the dataset and back up to the adapter and using the UPDATE query you specify makes the changes to the database

HTH
~BC
0
 
LVL 1

Author Comment

by:bryanford
ID: 17127085
Legend. Works perfectly.

Thanks
0
 
LVL 1

Author Comment

by:bryanford
ID: 17127679
Oh I also forgot to ask how would I execute a stored procedure that i have in that xsd dataset.

How would i go about that?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Integration Management Part 2

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question