?
Solved

Communication with SQL Server through Web Service

Posted on 2011-09-21
8
Medium Priority
?
324 Views
Last Modified: 2013-12-17
Hello Experts,

I have to make a contact's form with: ID, Name, Last name, Telephone etc. I created the tables in SQL Server everything is fine.

I need to connect to SQL Server through Web Service. So the communication between Database and C# should be done with Web service.

Can you please show me sample code? or direct me to a nice and easy tutorial?

Barlet
0
Comment
Question by:barlet
[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
  • 4
  • 3
8 Comments
 
LVL 17

Expert Comment

by:OriNetworks
ID: 36573364
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36573399
Here is good article to update database using web service
http://support.microsoft.com/kb/308056
0
 
LVL 7

Author Comment

by:barlet
ID: 36578836
@sonawanekiran
I really need something like it is in your link but in C# version... I already have the vb code sample..

I have this and tell me if you can change this code from vb to c# (sorry if this is out of the topic!)


Filename IService1.vb

 <OperationContract()>
Function LoadBooks() As DataTable

<OperationContract()>
Function InsertBooks(ByVal title As String, ByVal author As String, ByVal publisher As String,
                            ByVal ISBN As String, ByVal Description As String, ByVal Qty As String,
                            ByVal Price As String) As Boolean

Open in new window



Filename Service1.svc.vb
Public Function SearchBooks(ByVal searchtype As String, ByVal search As String) As DataTable Implements IService1.SearchBooks

Public Function DeleteBooks(ByVal BookID As Integer) As Boolean Implements IService1.DeleteBooks

Open in new window

0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 17

Accepted Solution

by:
sonawanekiran earned 2000 total points
ID: 36579078
C#

Filename IService1.vb

[OperationContract]
        public DataTable SearchBooks(string searchtype, string search);

        [OperationContract]
        public bool DeleteBooks(int BookID);

Open in new window



Filename Service1.svc.vb

public DataTable SearchBooks(string searchtype, string search)
        {
            // You code goes here
        }

        public bool DeleteBooks(int BookID)
        {
            // You code goes here
        }

Open in new window

0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36579103
OR
1. Open Visual studio
2. File >> New >> Project >> WCF Service (Make sure you should select  C# language)
3. Add above code in respective file
4. You need include System.Data to bring DataTable in scope
0
 
LVL 7

Author Comment

by:barlet
ID: 36579321
seems I cant figure it out...
let me be more clear... I have a Form1 in that form i have DataGridView and a button.
when I click to button should do 'select * from customers' but the query should be in web service side so no sql query is in client application...

I thought I will figure it out with conversion but I am really lost...
0
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 2000 total points
ID: 36579389
You client application should consume the wcf service. In you client application
1) Right click on your project, add service reference
2) Now you are able to make the call to SearchBooks() method of your wcf service
3) DataGridView.DataSource = //  call SearchBooks() method


0
 
LVL 7

Author Closing Comment

by:barlet
ID: 36583895
Thank you for your help...
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 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