0

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.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by kimlong008
0

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.

0

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();
        }
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.