Solved

Communication with SQL Server through Web Service

Posted on 2011-09-21
8
316 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
  • 4
  • 3
8 Comments
 
LVL 17

Expert Comment

by:OriNetworks
Comment Utility
0
 
LVL 17

Expert Comment

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

Author Comment

by:barlet
Comment Utility
@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
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 500 total points
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 17

Expert Comment

by:sonawanekiran
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Thank you for your help...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Xamarin 10 35
Hangfire / asp.net sample 3 27
Problem to picture file 3 36
Loop through Multiple Processes Async 2 15
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now