PC Review


Reply
Thread Tools Rate Thread

DataSets designed in wizard

 
 
rogersmail@gmail.com
Guest
Posts: n/a
 
      29th Nov 2005
Greetings,

I am new to this and have some problems.

I created a dataset using the vs2005 GUI and want to load the dataset
using code in the back end

I have:

XmlDocument xmlDoc = new XmlDocument();

dsSampleTableAdapters.tblSamplesTableAdapter sample = new
dsSampleTableAdapters.tblSamplesTableAdapter();

sample.GetSampleData(sample_id);

//DataSet ds = new DataSet
// dsSample ds = new dsSample
// xmlDoc = ds.GetXml();

Console.WriteLine(xmlDoc);
return xmlDoc;

The problem is that I am not sure where the sample.getSampleData is
acutally storing the data. I tried to set ds = sample.getSampleData
moving the new dataset lines above that obviously.

All I need to do is to retrieve the dataset I created in the gui and
return it as XML to a web service or as a custom object to a thick
client.

Any help is appreicatied.

Thanks
Roger

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      29th Nov 2005
Roger,

A XML document is rarely to process as a XML dataset.

A strongly typed dataset is even more restricted because it is a class
around (inheriting) a dataset.

If I have understood you well, than you can do what you want (assuming that
you have used the 2005 datasource wizard)
\\\
EmployeesTableAdapter.Fill(NorthwindDataSet.Employees)
NorthwindDataSet.WriteXml("C:\test1\test.xml")
///
(The table is translated direct by this to a dataset)

I hope this helps,

Cor

<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Greetings,
>
> I am new to this and have some problems.
>
> I created a dataset using the vs2005 GUI and want to load the dataset
> using code in the back end
>
> I have:
>
> XmlDocument xmlDoc = new XmlDocument();
>
> dsSampleTableAdapters.tblSamplesTableAdapter sample = new
> dsSampleTableAdapters.tblSamplesTableAdapter();
>
> sample.GetSampleData(sample_id);
>
> //DataSet ds = new DataSet
> // dsSample ds = new dsSample
> // xmlDoc = ds.GetXml();
>
> Console.WriteLine(xmlDoc);
> return xmlDoc;
>
> The problem is that I am not sure where the sample.getSampleData is
> acutally storing the data. I tried to set ds = sample.getSampleData
> moving the new dataset lines above that obviously.
>
> All I need to do is to retrieve the dataset I created in the gui and
> return it as XML to a web service or as a custom object to a thick
> client.
>
> Any help is appreicatied.
>
> Thanks
> Roger



 
Reply With Quote
 
rogersmail@gmail.com
Guest
Posts: n/a
 
      29th Nov 2005
Cor,

Thank you for the reply.

I did not create the Fill method as I did not want to fill a complete
database into memory.
Also the Fill and GetData method SQL statements seem to be the same.
I am not wanting to write it to a file.

What I need to do is to get the data from the database hence generating
the get method,
move it into XML and return it to the service layer. The service layer
will determine how to which client to deliver it to. I don't want my
webservice to return the dataset as it is called from various
platforms.

This code
dsSampleTableAdapters.tblSamplesTableAdapter sample = new
dsSampleTableAdapters.tblSamplesTableAdapter();

dsSample.tblSamplesDataTable data =
sample.GetSampleData(sample_id);

seems to load the datatable
but not the dataset

The reason for me using a dataset is that I have multiple databases
with a very complex schema. I figured that the dataset could handle
that better. But I have no idea how to return that as xml


Thanks
Roger

 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      29th Nov 2005
Roger,

I don't oversee the problem, however if you have the table and need that
into the dataset than it is simple.

\\\
DatasSt ds = new DataSet();
ds.Tables.Add("Your datatable");
ds.WriteXml("your path");
///

I hope this helps without investigating your problem.

Cor

<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Cor,
>
> Thank you for the reply.
>
> I did not create the Fill method as I did not want to fill a complete
> database into memory.
> Also the Fill and GetData method SQL statements seem to be the same.
> I am not wanting to write it to a file.
>
> What I need to do is to get the data from the database hence generating
> the get method,
> move it into XML and return it to the service layer. The service layer
> will determine how to which client to deliver it to. I don't want my
> webservice to return the dataset as it is called from various
> platforms.
>
> This code
> dsSampleTableAdapters.tblSamplesTableAdapter sample = new
> dsSampleTableAdapters.tblSamplesTableAdapter();
>
> dsSample.tblSamplesDataTable data =
> sample.GetSampleData(sample_id);
>
> seems to load the datatable
> but not the dataset
>
> The reason for me using a dataset is that I have multiple databases
> with a very complex schema. I figured that the dataset could handle
> that better. But I have no idea how to return that as xml
>
>
> Thanks
> Roger
>



 
Reply With Quote
 
rogersmail@gmail.com
Guest
Posts: n/a
 
      29th Nov 2005
I appreciate your time and patients. But what I need to know is when
you put
DataSet ds = new DataSet();
are you creating another dataset outside of the one you created in the
designer?

Adding tables I understand, but I only want to add one row of a
particular table and multiple rows of other tables. I can do that using
the relationships after I generate the SQL for the DataAdapter.

ds.WriteXml("your path")
Here is where I am having more trouble as I want to generate this in
memory only not to a disk.

Thanks you
Roger

 
Reply With Quote
 
rogersmail@gmail.com
Guest
Posts: n/a
 
      29th Nov 2005
Cor,

I really appreciate your help. But I need to bother you again if I
can.

I was thinking about your suggestion to write the XML file to a disk.
Some of the things I am worried about"
1. The file will be over written by another user
2. The resources required by each piece of the application to process
the document (reading and writing to the disk)

Am I worring about nothing?

Thanks
Roger

 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      30th Nov 2005
Rogers,

I realized me after sending that you would use it for a webservice.

I had trying something in 2005 a while back the same problem as you packing
it in that dataset as an envelope was than the solution.

ds.tables.add(table)

this create only a kind of wrapper (envelope) around your table.

the ds.writeXml(table) is only a way to test, although this is as well a
method to stream it should not be to disk.

Why don't you try it.

Cor

<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
>I appreciate your time and patients. But what I need to know is when
> you put
> DataSet ds = new DataSet();
> are you creating another dataset outside of the one you created in the
> designer?
>
> Adding tables I understand, but I only want to add one row of a
> particular table and multiple rows of other tables. I can do that using
> the relationships after I generate the SQL for the DataAdapter.
>
> ds.WriteXml("your path")
> Here is where I am having more trouble as I want to generate this in
> memory only not to a disk.
>
> Thanks you
> Roger
>



 
Reply With Quote
 
rogersmail@gmail.com
Guest
Posts: n/a
 
      30th Nov 2005
Cor,

Here is the basis of what I was looking for. I am posting this for
others to see.
I used your table add method instead of the connection strings they
give but I still need to touch up the XML as soon as I get it to print
out in my web page.

http://www.15seconds.com/Issue/040708.htm

public XmlDocument GetEmpDetailsByEmpID (int employeeID)
{
string connString =
System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConnection = new SqlConnection(connString);
try
{
DataSet employeeDataset = new DataSet("EmployeesRoot");
//Pass in the name of the stored procedure to be executed and the
SqlConnection
object as the argument
SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand command = new SqlCommand("Select * from Employees Where
EmployeeID ="
+ employeeID.ToString(),sqlConnection);
//Set the SqlCommand object properties
command.CommandType = CommandType.Text;
adapter.SelectCommand = command;
//Fill the Dataset with the return value from the stored procedure
adapter.Fill(employeeDataset,"Employees" );
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(employeeDataset.GetXml());
return xmlDoc;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (sqlConnection.State == ConnectionState.Open)
{
sqlConnection.Close();
}
}

Thank you very much for your help.

 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      30th Nov 2005
Roger,

It is nice that you found your solution, however if you pass it as dataset
you get the same result. This is almost standard Net 1.1 what you show. You
asked it for a DataSet designed with the wizard see your subject. Now it is
a little bit misleading for others.

This was enough for 1.1 without a wizard (I don't see what you do with the
exception here by the way, it looks for me as you let it be and than you can
take for the same the Using)

<WebMethod()>
public Dataset GetEmpDetailsByEmpID (int employeeID)
> {
> string connString =
> System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
> SqlConnection sqlConnection = new SqlConnection(connString);
> try
> {
> DataSet employeeDataset = new DataSet("EmployeesRoot");
> //Pass in the name of the stored procedure to be executed and the
> SqlConnection
> object as the argument
> SqlDataAdapter adapter = new SqlDataAdapter();
> SqlCommand command = new SqlCommand("Select * from Employees Where
> EmployeeID ="
> + employeeID.ToString(),sqlConnection);
> //Set the SqlCommand object properties
> command.CommandType = CommandType.Text;
> adapter.SelectCommand = command;
> //Fill the Dataset with the return value from the stored procedure
> adapter.Fill(employeeDataset,"Employees" );

return employeeDataset;
> }
> catch (Exception ex)
> {
> throw ex;
> }
> finally
> {
> if (sqlConnection.State == ConnectionState.Open)
> {
> sqlConnection.Close();
> }
> }
>



 
Reply With Quote
 
rogersmail@gmail.com
Guest
Posts: n/a
 
      30th Nov 2005
The lines I found most useful and should have posted was

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(employeeDataset.GetXml());
return xmlDoc;

The other code was just surrounding these lines. This will give a
dataset version of the XML doc, but I don't think that its possible to
get a standard format such as
<employee>
<first_name>joe</first_name>
<last_name>joe</last_name>
</employee>

I know I mixed employee with sample which was posted originally, but
the idea is there.

I posted a link for that reason that I wanted others to know where I
found it so they can read it too..

My apologies for misleading code.

Thanks
Roger

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? Francisco Garcia Microsoft ASP .NET 2 13th Apr 2006 11:41 AM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? news.microsoft.com Microsoft ASP .NET 0 12th Apr 2006 10:07 AM
Typed DataSets returned as regular datasets =?Utf-8?B?Sm9uIEtpbmc=?= Microsoft ADO .NET 2 29th Aug 2004 01:41 AM
Re: Wizard designed form (complicated) disallows input. Atlas Microsoft Access Form Coding 0 1st Apr 2004 10:32 AM
Converting Untyped Datasets into Strongly Typed Datasets with Foreign Key Constraints. Alex Berryhill Microsoft ADO .NET 2 19th Mar 2004 02:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:15 PM.