I T Tips

I T Tips Verified Official Page™ All Rights Reserved © ✔Verified Official Page✔ ©ORIGINAL PAGE® █?

Beams IT Solutions is an Excellent IT Training and finishing School on Android Training,Asp.net,Java, php,Sql,MySql etc.

HAPPY-XMAS
23/12/2013

HAPPY-XMAS

Not for job seeker's. One who wish to build him/his  career as software engineer.We now offers  4 months career developm...
05/12/2013

Not for job seeker's. One who wish to build him/his career as software engineer.

We now offers 4 months career development programme in various software devlopment technologies


Call us 9747364058/8281532293

Mail ur cv to [email protected]/
[email protected]

14/11/2013
Get XML of Table's Data using SQL Query==========================XML is now every where to exchange data between multipl...
26/10/2013

Get XML of Table's Data using SQL Query
==========================

XML is now every where to exchange data between multiple system and platform.
Here are sample query which retrieve XML of particular Table's data.

25/10/2013
24/10/2013

Consuming AJAX-Enabled WCF Services from both Client and Server

Step 1 - Create a solution and service project

a. Add a WCF Service Application project to the solution called FooService
b. Delete everything in the service project’s web.config file.

c. Create a class file called FooServiceOne.cs
d. Replace the code with this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

namespace GooberFoo.FooServices
{

[ServiceContract(Namespace = "GooberFoo.FooServices")]
public interface IFooServiceOne
{
[OperationContract]
double Add(double n1, double n2);
}

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class FooServiceOne : IFooServiceOne
{
public double Add(double n1, double n2)
{
return n1 + n2;
}
}
}

e. Create another file called FooServiceOne.svc and past the following code into the file.


f.Save and Compile

Step 2.Host the service is IIS

a. Make sure "Enable anonymous access" is checked.
b. Make sure "Integrated Windows authentication" is unchecked.
c. Test the service by navigating to http://GooberServer:90/FooServiceOne.svc
d. The service will be displayed with the message "Metadata publishing for this service is currently disabled."

Step 3 - Access the service from the client-side code

a. Create an Empty ASP.NET Web Application in your solution.
b. Drag and drop an AJAX Extensions ScriptManager control into your web page.
c. In the ServiceReference Collection Editor, set the path to http://GooberServer:90/FooServiceOne.svc
d. Drag and Drop an ASP.NET button and Label control on the page.




e.
Add client-side script.

Collapse | Copy Code


function onSuccess(result) {
document.getElementById('').innerHTML = result;
}
function Button1_Click() {
var proxy = new GooberFoo.FooServices.IFooServiceOne();
proxy.Add(parseFloat(5), parseFloat(7), onSuccess, null, null);
return false;
}

f. Compile and test.

Modify the service project to allow server-side code to consume the service

Change the service project's web.config file to look like this.

?xml version="1.0"?>





































Step 5: Test the Service.

1. In IE, open the URL http://GooberServer:90/FooServiceOne.svc.
2. You will see the FooServiceOne Service page along with instructions to use svcutil.exe http://GooberServer:90/FooServiceOne.svc?wsdl
Step 6 - Add the Web Reference to your asp.net web application.

a In your web application, "Add Service Reference".
b. Use http://GooberServer:90/FooServiceOne.svc?wsdl
c. Click Go.
d. Use FooServiceOneRef as the namespace.
e. Click OK.
f. View web application’s web.config file.
i.It’s changed quite a bit.
ii.You will see the system.serviceModel node that includes the bindings and client nodes.
iii. You will not need to change anything.

Step 7. Use server-side C # code to consume the service in your web application.

a. Add Button control to the page along with a button click event.

b. The button click event will look like this:
protected void Button2_Click(object sender, EventArgs e)
{
FooServiceOneRef.FooServiceOneClient mySvc = new FooServiceOneRef.FooServiceOneClient();
Label1.Text = Convert.ToString(mySvc.Add(10, 13));
}
c. Compile and test.

Generic Web handler (*.ashx, extension based processor) is the default HTTP handler for all Web handlers that do not hav...
13/06/2013

Generic Web handler (*.ashx, extension based processor) is the default HTTP handler for all Web handlers that do not have a UI and that include the directive.

ASP.NET page handler (*.aspx) is the default HTTP handler for all ASP.NET pages.

Among the built-in HTTP handlers there are also Web service handler (*.asmx) and Trace handler (trace.axd)

An Indroduction to Object Oriented Programming ...
10/06/2013

An Indroduction to Object Oriented Programming ...

31/05/2013

How to INSERT data from Stored Procedure to Table – 2 Different Methods

1) When the table is already created and 2) When the table is to be created run time. In this blog post we will explore both the scenarios together.

However, first let us create a stored procedure which we will use for our example.

CREATE PROCEDURE GetDBNames
AS
SELECT name, database_id
FROM sys.databases
GO

We can execute this stored procedure using the following script.

EXEC GetDBNames

Now let us see two different scenarios where we will insert the data of the stored procedure directly into the table.

1) Schema Known – Table Created Beforehand

If we know the schema of the stored procedure resultset we can build a table beforehand and execute following code.

CREATE TABLE ([name] NVARCHAR(256), [database_ID] INT);
INSERT INTO
EXEC GetDBNames
-- Select Table
SELECT *
FROM ;

The disadvantage of this code is that if due to any reason the stored procedure returns more or less columns it will throw an error.

2) Unknown Schema – Table Created at Runtime

There are cases when we do know the resultset of the stored procedure and we want to populate the table based of it. We can execute following code.

SELECT * INTO FROM OPENROWSET('SQLNCLI', 'Server=localhost;Trusted_Connection=yes;',
'EXEC tempdb.dbo.GetDBNames')
-- Select Table
SELECT *
FROM ;

The disadvantage of this code is that it bit complicated but it usually works well in the case of the column names are not known.

Just note that if you are getting error in this method enable ad hoc distributed queries by executing following query in SSMS.

sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO

I will be interested to know which of the above method do you use in your projects? and why?

Address

Malappuram

Alerts

Be the first to know and let us send you an email when I T Tips posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share