Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Configuration;
- namespace WebApplication21
- {
- public partial class WebForm1 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
- con.Open();
- SqlCommand cmd = new SqlCommand("select * from 'user_insert' where username = @username and password = @password,con");
- cmd.Parameters.AddWithValue("@username", TextBox1.Text);
- cmd.Parameters.AddWithValue("@password", TextBox2.Text);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- da.Fill(dt);
- if (dt.Rows.Count > 0)
- {
- Response.Redirect("Welcom.aspx");
- }
- else
- {
- Response.Redirect("Error.aspx");
- }
- }
- <connectionStrings>
- <add name="dbconnection" connectionString="Data Source=Ali-PC;Initial Catalog=LogIn;Integrated Security=True"/>
- </connectionStrings>
- SqlCommand cmd = new SqlCommand
- (@"select * from 'your table' where username = @username and password = @password",con);
- cmd.Parameters.AddWithValue("@username", TextBox1.Text);
- cmd.Parameters.AddWithValue("@password", TextBox2.Text);
- DataTable dt = new DataTable();
- dt.Load(cmd.ExecuteReader());
Add Comment
Please, Sign In to add comment