Solved

Problem with dataset

Posted on 2006-07-17
7
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 250 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…

739 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