473,903 Members | 4,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading a DataSet - Newby

I have an applicatioin that I'm writing that uses a "case" file that
contains over 350 columns and more may be added in the future. I would like
to create a dataset with all the column names and only one case record that
is delivered by a stored procedure. (I have a stored procedure that works
so my question is only on loading the DataSet.)

The DataSet will only be used for printing form letters and then will be
zapped. I would like to do it this way rather than maintain a stored
procedure that returns 350 variables if possible so that I don't have to add
new code each time a column is added.

For example:

dim myDataSet as DataSet = New Dataset("MyCase Data")
dim myCaseTable as DataTable = New DataTable
dim my

dim caselib as new data.caselib
mycasetable = caselib.getoner ec(case#) // returns an sql reader with one
record

So: I guess I'm asking how to define a data set and load data columns and
data from an SQL Data Reader

Then I would access the info by column name.

At the end of the process I would set the myDataSet = nothing

Any help or pointers to where to look to do this would be GREATLY
appreciated!

Thanks,

Fred
Nov 20 '05 #1
4 1777
To get the original 350 fields (instead of typing them in) create a strongly
typed dataset, then in your server explorer, go to your sql connection for
you rdatabase, find the stored procedure, and drag that onto your newly
created dataset. This will populate your first 350 fields, then every field
after that, you can just easily add to the bottom of the list.

HTH,
CJ
"Fred Nelson" <fr**@smartybir d.com> wrote in message
news:O3******** ******@TK2MSFTN GP09.phx.gbl...
I have an applicatioin that I'm writing that uses a "case" file that
contains over 350 columns and more may be added in the future. I would like to create a dataset with all the column names and only one case record that is delivered by a stored procedure. (I have a stored procedure that works
so my question is only on loading the DataSet.)

The DataSet will only be used for printing form letters and then will be
zapped. I would like to do it this way rather than maintain a stored
procedure that returns 350 variables if possible so that I don't have to add new code each time a column is added.

For example:

dim myDataSet as DataSet = New Dataset("MyCase Data")
dim myCaseTable as DataTable = New DataTable
dim my

dim caselib as new data.caselib
mycasetable = caselib.getoner ec(case#) // returns an sql reader with one
record

So: I guess I'm asking how to define a data set and load data columns and
data from an SQL Data Reader

Then I would access the info by column name.

At the end of the process I would set the myDataSet = nothing

Any help or pointers to where to look to do this would be GREATLY
appreciated!

Thanks,

Fred

Nov 20 '05 #2
Hi Fred,

I do not know what to think from your question, or you are teasing us or you
are really a newby in dotNet. I was in doubt if I would write an answer,
however it intrigue me.

Making a datatable with 350 rows and 1 column cost no time at all and is
endless extensible.

Setting the dataset to nothing is a useless operation and should be avoided.

Using the datareader and fill a dataset is not done, because for that is the
dataadapter fill special made.

And maybe your problem is even better to do when you have really a table
with only one row simple using only the datareader (or maybe when you want
only one value from that table using the executenonscala r).

However it is "posible" in the way as CJ told you .

Cor

Nov 20 '05 #3
Cor:

Thanks for your reply! Let me assure that this is not "teasing"! And I'm
VERY new to this!

I have an application that tracks medical records for hospital patients and
there is an ever increasing amount of information that is required on a
routine basis. (I've been supporting this application for almost 11 years
and I am now converting it to use SQL 2000 and VB.Net). The main case
database really does have over 350 columns!

The design goal is to reduce the impact of adding the new fields -
especially in the part of the system that generates standard form letters.
In the existing system users are able to add references to new fields and
then the information is interpreted and obtained from a FoxPro database.
Any of the 350 fields may be needed in a letter or report.

In the new system I would like to be able to use a stored procedure that is
simple, for example:

SELECT * from CASEMAST where cs_ident = @p_searchid

This would of course return only one record. Then I would like to create,
define, and load a dataset with one record (0) that I could reference by
colum name(0).

When I said that I was going to set the dataset to nothing I meant that
after the letters were generated I would not need the data any longer - no
updates would be sent back to the database.

It appears that this is not going to be possible so I will need to create a
stored procedure with 350 parameters and add the new fields as needed.

Fred
"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uD******** ******@TK2MSFTN GP11.phx.gbl...
Hi Fred,

I do not know what to think from your question, or you are teasing us or you are really a newby in dotNet. I was in doubt if I would write an answer,
however it intrigue me.

Making a datatable with 350 rows and 1 column cost no time at all and is
endless extensible.

Setting the dataset to nothing is a useless operation and should be avoided.
Using the datareader and fill a dataset is not done, because for that is the dataadapter fill special made.

And maybe your problem is even better to do when you have really a table
with only one row simple using only the datareader (or maybe when you want
only one value from that table using the executenonscala r).

However it is "posible" in the way as CJ told you .

Cor


Nov 20 '05 #4
Hi Fred

I think that it is very easy in dotnet to do this

Make a connection string
www.connectionstrings.com

Than you can make a connection
dim conn as new sqlclient.conne ction(connectio nstring)

A command (you can also use the selectcommand in the adapter however this
shows nicer)
Dim cmd As New SqlCommand("EXE CUTE MYDATABASE.dbo. SelectMySelect" , conn)
cmd.Parameters. Add(New SqlParameter("@ p_Searchid", SqlDbType.NVarC har,
200)).Value = Whatever

Than the dataset
dim ds as new dataset

Than the dataadapter
dim da as new sqlclient.sqlda taadapter(cmd)

fill the dataset
da.fill(ds)

Use the 50th field of your dataset to show in a messagebox
messagebox.show (ds.tables(0).r ows(0)(49).toSt ring) 'instead of the 49 you
can use the columname between "" remember that is case sensetive.

In your situation you do not have to open or close the connection because
that does the dataadapter for you, however you can set the dataadapter in a
try and catch block and than that fill is.

try
da.fill(ds)
catch ex as exception
messagebox.show (ex)
end try

I hope this helps, everything is of course typed in above so watch typos see
it as pseudo code.

Cor


Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4501
by: Patrick J. Schouten | last post by:
I am trying to transfor an XML document prior to loading into a Dataset. My problem stems from the known bug in Visual Studio that prevents loading a well formed XML because of duplicate child names: http://support.microsoft.com/default.aspx?scid=kb;en-us;325696 Anyway, I want to transform the XML using the XSLT to get around this problem, but I am having a tough time coming up with a way to apply the XSLT before loading it into the...
0
1240
by: J-T | last post by:
I have a CSV file which contains comma seperated data that I need to validate against our database.I was thinking about loading that CSV file into a Typed-Dataset which has our database schema in it and then try to load the CSV file into that Typed-Dataset and automatically get all the errors and constarint violations. 1) Is it doable? 2) Because I need to check the foriegn keys as well,Can I loaded the data of those refferecing...
1
3162
by: kids_pro | last post by:
I had come across a code block from Loading a DataSet from XML (.NET Framework Developer's Guide) ---------------------------------------- NOte If you call ReadXML to load a very large file, you may encounter slow performance. To ensure best performance for ReadXml, on a large file, call the DataTable.BeginLoadData method for each table in the DataSet, then call ReadXml. Finally, call DataTable.EndLoadData for each table in the DataSet as...
10
2945
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several routines that upload and process images. I can't get past "square one" with images in C#: This statement:
4
357
by: Fred Nelson | last post by:
I have an applicatioin that I'm writing that uses a "case" file that contains over 350 columns and more may be added in the future. I would like to create a dataset with all the column names and only one case record that is delivered by a stored procedure. (I have a stored procedure that works so my question is only on loading the DataSet.) The DataSet will only be used for printing form letters and then will be zapped. I would like...
2
2508
by: krunom | last post by:
Hi, i am a newby in Crystal Reports design, and i wrote a c# windows form application that creates a DataSet. And, now i want to pass this DataSet to CrystalReport (via DataSource?) and i do not know how to display this DataSet in my Crystal Report :( Please, help.
7
1814
by: koonda | last post by:
Hi guys, I am trying to create a web interface in C# using ASP.NET. The database being used is SQL Server. I have some problems loading the tables in the datalist controls. When I run the program the DataList controls are loaded not with tables but something like this: "System.Data.DataRowView" in the three list boxe controls. Because I have three tables and I want to load them in the three list box controls. And then I want to select values...
0
2029
by: Chris | last post by:
Hello, I have a problem with re-loading datasets. As a simple example, if I have an SQL table of addresses comprising active and inactive addresss, I wish to load either sub-set by clicking on a checkBox. The data is Bound to various controls on a Windows Form. This works fine, I can load either set of data into the same
6
5072
by: cmorgan76 | last post by:
This is a 2 part question: Part 1: I am accesing a web service that returns an xml string of user information. I am attempting to load the XML into an XMLDocument, save the document, load it into a dataset, and bind the dataset to a gridview. I'm not sure if it's neccesary to save the XML file to disk, but I wanted to make sure it was well formed. It is. No exceptions are caught during the loading and binding process, but my gridview...
2
2474
by: yaaadman | last post by:
Hello Guys, I am trying to retrieve some rows from a temporary table in a stored procedure. In my stored procedure I have SELECT * FROM #TempTable. In Visual Basic (2005) Console I have: Dim myConn As New System.Data.SqlClient.SqlConnection Dim myAdapter As New System.Data.SqlClient.SqlDataAdapter Dim mySelectCommand As New System.Data.SqlClient.SqlCommand Dim myDataset As New System.Data.DataSet Dim I...
0
10007
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11297
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10882
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
4316
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.