Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with dataset

Posted on 2006-07-17
7
Medium Priority
?
184 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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 …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

670 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