I have created a c# file to create namespacing for refering connection and dataset.
includes.cs (for creatomg namespace Logic)
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- namespace Logic
- {
- public class Includes
- {
- public void executeQuery(string strsql)
- {
- string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
- SqlConnection con = new SqlConnection(conn);
- SqlCommand cmd = new SqlCommand(strsql, con);
- try
- {
- con.Open();
- cmd.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- con.Close();
- con.Dispose();
- cmd.Dispose();
- }
- }
- public DataSet getDataSet(string strsql)
- {
- string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
- SqlConnection con = new SqlConnection(conn);
- SqlCommand cmd = new SqlCommand(strsql, con);
- try
- {
- con.Open();
- SqlDataAdapter ad = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- ad.Fill(ds);
- return ds;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- con.Close();
- con.Dispose();
- cmd.Dispose();
- }
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using Logic;
- using System.Data.SqlClient;
- public partial class test : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- Includes obj = new Includes();
- string uname = uid.Text.Trim();
- string pass = pwd.Text.Trim();
- string sql = "select user_id,user_pass,user_status from user_master where user_id='" + uname + "' and user_pass='" + pass + "'";
- DataSet ds = obj.getDataSet(sql);
- int ctr=ds.Tables[0].Rows.Count;
- if (ctr > 0)
- {
- string stat = ds.Tables[0].Rows[0]["user_status"].ToString();
- if ( ds.Tables[0].Rows[0]["user_status"].ToString()== "Y")
- {
- Response.Redirect("main.aspx");
- }
- else
- {
- Response.Redirect("index.aspx");
- }
- }
- else
- {
- Response.Redirect("index.aspx");
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- <connectionStrings>
- <add name="conn" connectionString=" Server=xxx.db.xxxx.hostedresource.com; Database=xxx; User ID=xxx; Password=xxx; Trusted_Connection=False" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString=" Server=xxx.db.xxxx.hostedresource.com; Database=xxx; User ID=xxx; Password=xxx; Trusted_Connection=False" providerName="System.Data.SqlClient" />
- </connectionStrings>
- <configuration>
- <system.webServer>
- <httpErrors errorMode="Detailed" />
- <asp scriptErrorSentToBrowser="true"/>
- </system.webServer>
- <system.web>
- <customErrors mode="Off"/>
- <compilation debug="true"/>
- </system.web>
- </configuration>
Please I need help