adam gills

adam gills

  • NA
  • 65
  • 14.3k

create connection class in C#(windows application:vs2008)

Oct 4 2016 2:08 AM
Dear Sir,
Good morning !
I create a connection class in C# and i want to access it in my windows form application.
so plz help me how to get connection class in my windows form application.so that is can do insert,update and delete.
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace BrowseUrl
{
class globalconn
{

SqlDataAdapter adp = new SqlDataAdapter();
SqlCommand cmd=new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter();

public static SqlConnection GetConnection()
{
string constr = "Data Source=XXX.XX.XXX.XXX;Initial Catalog=mydb;User ID=xyz;Password=123456789";
SqlConnection conn = new SqlConnection(constr);
conn.Open();
return conn;
}


}
}

Answers (3)