DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Conectarte A Una Base De Datos Con .net
// description of your code here
SqlConnection conn = null;
SqlCommand cmd = null;
SqlDataReader dr = null;
String s = null;
Product prod = null;
try
{
conn = new SqlConnection("Provider=SQLOLEDB;SERVER=sissql2;UID=sa;PWD=AlfaRoma440;DATABASE=genericatest2");
s = " ";
cmd = new SqlCommand(s,conn);
dr = cmd.ExecuteReader();
// lleno el objeto producto
while( dr.Read())
{
}
}
catch (Exception ex)
{
// poner el manejo de errores
}
finally
{
dr.Close();
conn.Close();
}
dr.Close();
conn.Close();
return prod;
}




