Never been to DZone Snippets before?

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

About this user

Ivan

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

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;
}
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS