use asp.net using c# coding
i have to connect local Pc to server that is ( from my website i need to retrieve data from my local PC) use asp.net using c# coding . how to do it
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
selvi subramanianPosted Apr 5, 2014, 4:57 AM
SqlConnection connection = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=tests;Data Source=MAK-PC\SQLEXPRESS");
Ramasagar PulidindiPosted Apr 5, 2014, 3:37 AM
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace myData
{
public static class Data
{
public static DataTable GetSampleData()
{
SqlConnection connection = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=tests;Data Source=MAK-PC\SQLEXPRESS");
SqlCommand cmd = new SqlCommand("select * from sampleData", connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
try
{
connection.Open();
da.Fill(ds);
}
catch (Exception e)
{
throw;
}
finally
{
if (connection.State == System.Data.ConnectionState.Open)
connection.Close();
}
return ds.Tables[0];
}
}
}