472,364 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

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 1680
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.