If I want to make a file connect SQL by file C# which I don't use connect in web.config But I can't call 2 class because when file aspx and Cs they have call

public partial class _Default : System.Web.UI.Page

Help me create file connect SQL in Cs use all file !

I have create file cs và use namespace but It's error when I call it to other file Cs.

I'm guessing that you want to connect to a SQL database from a class file that's not part of an aspx page? All you have to do is create a .cs file in your App_Code folder, and you can pretty much do what you want from there. I traditionally make a file called DBHandler.cs, in it's constructor I make a connection to the database, and then open it as I need to perform SQL tasks.

I had create file connect but I don't know call It which use same to web.config,
I want to file connect to all file with truct as web.config
Ex : In web.config

<connectionStrings>
		<add name="Data_ConnStr" connectionString="Data Source=Local;Initial Catalog=SMSLogin;User ID=sa;Password=123456" providerName="System.Data.SqlClient"/>
	</connectionStrings>

"Data_ConnStr" call to using,
so String connect in file Cs how do call to using ?

this is String Connect I use in file cs :

SqlConnection conn;
        DataSet ds;
        SqlDataAdapter da;
        public Modules()
        {
            string sConn = "provider=sqloledb;server=HOME-KIMLONG;database=MyDatabase;Integrated Security=SSPI";
            OleDbConnection oConn = new OleDbConnection(sConn);
            oConn.Open();
        }

If I want to make a file connect SQL by file C# which I don't use connect in web.config But I can't call 2 class because when file aspx and Cs they have call

public partial class _Default : System.Web.UI.Page

Help me create file connect SQL in Cs use all file !

I have create file cs và use namespace but It's error when I call it to other file Cs.

http://www.codeproject.com/KB/dotnet/ADONET_ConnectionPooling.aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.