Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Send Dataset to Webservice!!Urgent please help

Posted on 2004-08-07
12
Medium Priority
?
437 Views
Last Modified: 2012-06-27
Hi,
I'm faced with the following problem:

1) I'm trying to send some information from a client to a webservice. Now, this information happens to be a dataset which contains all the data in a table(select * query).
Problem/Question: Can i send a DATASET to the webservice as a parameter??? If so, how??
Qn 2: If i send the dataset to the webservice is it possible for me to create a relational table on the web service's side with the data set that has been passed by the client.

Please help....It is very urgent and i'm clueless as to how to proceed.

Thanks,
0
Comment
Question by:srik18
[X]
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
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11744373
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11744471
actually aeros thats backwards, thats consuming a dataset from a webservice.

you would just pass a dataset to the method as normal ...

public function Whatever(byval ds as DataSet)
end function


then you are asking to create a relational table ... do you mean to create a table in your database based on the dataset ?

0
 

Author Comment

by:srik18
ID: 11744655
Hi Guys,
Thanks a lot for your quick responses.

gregoryyoung:
Yes that is right i need to construct a relational database from the dataset thats being sent to the webservice. That is this database is not currently available at the place where the webservice is available. So i need to create a database on an SQL Server based on this dataset that i am getting from the client.

I hope i am clear.

Aeros:
Thank you for the link but if i am not wrong the link explains how to update a database ASSUMING that the database is available on both the client side and the place where the webservice is located.

Hope you guys can clear my problem. :)
Thanks a lot once again.
S
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11744729
am I right in assuming that the tables do not currently exist at the site where the webservice is ? or is it a buch of clients sending up similar data which needs to be merged ?
0
 

Author Comment

by:srik18
ID: 11744863
Hi Mr.Gregory Young,
Yes, You are right. The table does not exist where the webservice is. Each client sends the FULL dataset of a particular database with each request that is, we are not merging the data at the webservice from various clients.
This dataset from a single client needs to be converted into a database.
Thanks a lot once again.
S.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11744882
not sure on the actual create, but once the table is there you will be using the sqlcommandbuilder object, similar to here http://www.devarticles.com/c/a/ADO.NET/Automatic-Generation-of-Single-Table-SQL-Statements-in-.NET/
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 11747893
Hi srik18,

from what you are posting i understand that you want to do things like this

1. in web service receive dataset from the client
2. in your database create a datatable based on the structure of the datatable objects in the collection dataset.tables ( is there ony one datatable in your dataset collection ? )
3. Fill the created table with the data from the dataset

is this correct ?

B..M
0
 

Author Comment

by:srik18
ID: 11748296
Hi Mr.Marinov,
Yes you got it right.
What i want is
1) send dataset from client...which i have actually achieved at the moment.
2) in my database (which is at the location of webservice) create the datatable based on the objects in dataset.tables.
3) Fill the table with data from the dataset(that is recreate the same data table on the webservice side when the only information you have is the dataset.)
The dbms we are using is SQL Server.
We are currently trying to use the readXML schema and writeXMLschema methods but we are stuck at the moment...if u have any other approach or have code samples to show how this can be done that would be great.

Thanks a lot.
S.

p.s: Taking the question to another level :    
can we create a database also on the webservice side . That is suppose the client sends the name of the table and name of the database ex: customers and Northwind. Can we create a database on the webservice side named northwind and can we create a datatable in that database called customers.--> all through code.
I am of the opinion that the database cannot be created and hence i am assuming that the database is already present at the webservice side but the database does not have the datatable whose dataset the client is sending.
Hope i am clear. Sorry for the late response.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11748469
yes you can, although I believe you will have to write the code to create the database/table on your own. One issue that you will run into here is field sizes/precision.

0
 

Author Comment

by:srik18
ID: 11748513
Hi Mr.Gregory Young,
Can you give us a code sample(that goes into the webMethod) showing us how it can be done....assuming that we give fixed(hard coded) field sizes ??
How do we create a database and datatable?
Thanks.
S
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 2000 total points
ID: 11750751
using this statement
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='your table name' you can get the structure of the table and like this

private static string BuildStringForCreae(DataTable _dt, DataTable _dt_rows )
        {
            if ( _dt == null )
                return null;

            StringBuilder sb = new StringBuilder();

            for ( int _field_index = 0; _field_index < _dt.Rows.Count; _field_index++ )
            {
                sb.Append ( _dt.Rows[_field_index]["COLUMN_NAME"].ToString() + " " +
                    _dt.Rows[_field_index]["DATA_TYPE"].ToString());

                if (_dt.Rows[_field_index]["DATA_TYPE"].ToString() == "char"||
                    _dt.Rows[_field_index]["DATA_TYPE"].ToString() == "nchar" ||
                    _dt.Rows[_field_index]["DATA_TYPE"].ToString() == "nvarchar")
                    sb.Append (" (" + _dt.Rows[_field_index]["CHARACTER_MAXIMUM_LENGTH"].ToString() + ")");

                if ( (bool)_dt_rows.Columns[_dt.Rows[_field_index]["COLUMN_NAME"].ToString()].AutoIncrement )
                    sb.Append (" IDENTITY ( " + _dt_rows.Columns[_dt.Rows[_field_index]["COLUMN_NAME"].ToString()].AutoIncrementSeed + "," + _dt_rows.Columns[_dt.Rows[_field_index]["COLUMN_NAME"].ToString()].AutoIncrementStep + " )" );

                if ( _dt.Rows[_field_index]["IS_NULLABLE"].ToString().Trim() == "No")
                    sb.Append(" NOT NULL" );
                else
                    sb.Append(" NULL ");

                if ( _dt.Rows[_field_index]["COLUMN_DEFAULT"]!= DBNull.Value)
                    sb.Append( " DEFAULT '" + _dt.Rows[_field_index]["COLUMN_DEFAULT"].ToString() + "'");

                if ( _field_index != _dt.Rows.Count-1 )
                    sb.Append(","+Environment.NewLine);
            }

            return sb.ToString() + " ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] ";
        }

to create  your own create sql script, where
_dt is the table return by the sql statement
the _dt_rows are the rezults which will be inserted

after creating the create script, execute it and then create insert statement for every row in the _dt_rows datatable

Regards,
B..M
0
 

Author Comment

by:srik18
ID: 11758814
Hi MMarinov,
Thanks a lot for the code. We are doing it in a different way but the code was helpful elsewhere....i am giving you the points. I am posting another question which i believe is relatively simple...please kindly help if you can.
Thanks a lot.
S
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

670 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