I am newbie in this field and facing some problem. Please some one can tell or give the code to connect with database in ASP.NET?
Is it so hard to use google? http://www.w3schools.com/aspnet/aspnet_dbconnection.asp Just by searching google with connect with database in ASP.NET example
I agree with Eric. You will have better use of your time by searching on Google instead of waiting for replies here.
i don't know which database u want to connect,but in oracle to connect with yr db following query are used.. ]$ export ORACLE_SID=databasename linux os ]$sqlplus / as sysdba sql>startup
We are going to use the Northwind database in our examples. First, import the "System.Data.OleDb" namespace. We need this namespace to work with Microsoft Access and other OLE DB database providers. We will create the connection to the database in the Page_Load subroutine. We create a dbconn variable as a new OleDbConnection class with a connection string which identifies the OLE DB provider and the location of the database. Then we open the database connection:
Try this asp.net database connection sample..... http://asp.net-informations.com/ado.net/asp-database-program.htm Dell
use web.config to store the connection string like this - <connectionStrings> <add name="saCS" connectionString="Data Source=MyDatabase.db.105435095.hostedresource.com;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=MyDatabase;Password=vewxas9tn0M4@" providerName="System.Data.SqlClient"/> </connectionStrings> Explanation - saCS - connection string name . Data Source - database server location Initial Catalog - database name User ID - your database user id password - its password Use this connection string in your c# page to make the connection like - SqlConnection conn; SqlCommand cmd; SqlDataAdapter sqlDataAdapter; DataSet dataSet; public BlogDal() { conn = new SqlConnection(); cmd = new SqlCommand(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["saCS"].ConnectionString; cmd.Connection = conn; } FInally execute the stored procedure or retrive data from stored procedure, etc. Hope it is clear.