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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ramasagar PulidindiRank #163 · 14.4K reputationPosted Apr 4, 2014, 11:37 PM EDT
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];
}
}
}
selvi subramanianRank #2,007 · 723 reputationPosted Apr 5, 2014, 12:57 AM EDT
SqlConnection connection = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=tests;Data Source=MAK-PC\SQLEXPRESS");