Solved

Problem with dataset

Posted on 2006-07-17
7
176 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now