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
Solved

Problem with dataset

Posted on 2006-07-17
7
180 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web Form VB.Net  import CSV 4 44
Crystal reports vb.net 2 54
MailAddress in vb 4 29
VS 2015 is giving [No relevant source lines] 2 29
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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