473,465 Members | 4,823 Online
Bytes | Software Development & Data Engineering Community
Create 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("MyCaseData")
dim myCaseTable as DataTable = New DataTable
dim my

dim caselib as new data.caselib
mycasetable = caselib.getonerec(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 1744
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**@smartybird.com> wrote in message
news:O3**************@TK2MSFTNGP09.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("MyCaseData")
dim myCaseTable as DataTable = New DataTable
dim my

dim caselib as new data.caselib
mycasetable = caselib.getonerec(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 executenonscalar).

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**********@planet.nl> wrote in message
news:uD**************@TK2MSFTNGP11.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 executenonscalar).

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.connection(connectionstring)

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

Than the dataset
dim ds as new dataset

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

fill the dataset
da.fill(ds)

Use the 50th field of your dataset to show in a messagebox
messagebox.show(ds.tables(0).rows(0)(49).toString) '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
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...
0
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...
1
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...
10
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...
4
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...
2
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...
7
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...
0
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...
6
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...
2
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
1
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...
0
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.