Code:
namespace VendorProjNew
{
public partial class frmLogIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
string str = System.Configuration.ConfigurationManager.ConnectionStrings["VendorNewConnectionString"].ConnectionString;
protected void btnSubmit_Click1(object sender, EventArgs e)
{
// to validate some field
if (this.Page.IsValid)
{
SqlConnection Objcon = new SqlConnection(str);
// to store the data
DataTable dt = new DataTable();
// opening the connection
Objcon.Open();
// passing the Sp name and the conn name
SqlCommand oCmd = new SqlCommand("SP_Login_validate", Objcon);
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Parameters.AddWithValue("@vname", txtVendorName.Text);
oCmd.Parameters.AddWithValue("@pwd", txtPasssword.Text);
// to get details through database is accessed using data adapter
SqlDataAdapter da = new SqlDataAdapter(oCmd);
da.Fill(dt);
oCmd.ExecuteNonQuery();
Objcon.Close();
Response.Redirect("VendorDetails.aspx");
}
}
}
}
create procedure SP_Login_valida te
@pwd nvarchar(20),
@vname nvarchar(50)
as
begin
SELECT [Password]
,[VendorName]
FROM [VendorNew].[dbo].[Login] where Password=@pwd and VendorName =@vname
end
Comment