Ver Mensaje Individual
  #4 (permalink)  
Antiguo 15/07/2008, 14:28
diegolo
 
Fecha de Ingreso: enero-2008
Mensajes: 144
Antigüedad: 16 años, 4 meses
Puntos: 2
Respuesta: conexion a servidor de hosting

HABER TE CREAS UNA CLASE EN TU PROYECTO LLAMADA CLASES, PEGA ESTO
public SqlConnection conexion;
public SqlCommand comando;
public SqlDataReader dReader;
public SqlDataAdapter myCommand;
public string sql="";

public void AbrirConexion()
{
string path = "workstation id=IPDELSERVIDOR O 127.0.0.1;packet size=4096;user id=sa;data source=(local);persist security info=False;initial catalog=NOMBRE DE LA BASE EN SQL";
conexion=new SqlConnection(path);
this.conexion.Open();
}

public SqlDataReader VerDatos(string sql)
{
this.AbrirConexion();
comando=new SqlCommand(sql,this.conexion);
dReader=this.comando.ExecuteReader();
return dReader;
}

public void EjecutarSql(string sql)
{
this.AbrirConexion();
this.comando=new SqlCommand(sql,conexion);
this.comando.ExecuteNonQuery();
}

public DataSet VerDatosGrid(string sql)
{
AbrirConexion();
myCommand=new SqlDataAdapter(sql,conexion);
DataSet ds=new DataSet();
myCommand.Fill(ds);
return ds;
}