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.io.ports;
using system.collections.generic;
using system.data.sqlclient;
public partial class _default : System.web.ui.page
{
public void a()
{
session["mysession"] = "a";
}
protected void page_load(object sender, eventargs e)
{
}
protected void button1_click(object sender, eventargs e)
{
}
protected void button1_click1(object sender, eventargs e)
{
//----- create conection for dbase -----------------------------------------------------------------
sqlconnection sconection = new sqlconnection("data source=hostip;initial catalog=dbase name;user id=user name data base;password=pass data base");
//----- create data adaptor for calling and sendig the comand -------------------------
sqldataadapter sadaptor = new sqldataadapter("select * from log ", sconection);
//----- create cmd note for sending to dbase ---------------------------------------
string insertcmd = "select usnam, pas " +
"from log " +
"where usnam = '" + textbox1.text + "' and pas = '" + textbox2.text + "'";
//----- matching cmd note with conection ------------------
sqlcommand scomand = new sqlcommand(insertcmd, sconection);
//==================================================================================
//----- comand parametr and chose data type----------------------
//scomand.parameters.add(new sqlparameter("@usnam", sqldbtype.varchar));
//----- declare the values -----------------------
//scomand.parameters["@usnam"].value = textbox1.text;
//==================================================================================
//----- comand parametr and chose data type------------------------
//scomand.parameters.add(new sqlparameter("@pas", sqldbtype.varchar));
//----- declare the values -------------------------
//scomand.parameters["@pas"].value = textbox2.text;
//==================================================================================
//----- sending comand and open & execute the query --------------
scomand.connection.open();
string strresult = string.empty;
strresult = (string)scomand.executescalar();
//int strresult = (int)scomand.executenonquery();
//a = textbox1.text.tostring;
response.write(strresult);
label4.text = strresult;
if (label4.text.length != 0)
{
a();
response.redirect("cmain.aspx");
}
else if (label4.text.length == 0)
{
label3.text = " cn ";
}
//----- create data set ----------------------------------------------
dataset ds = new dataset();
//----- mathing data set with table in data base----------------------
sadaptor.fill(ds, "log");
//----- close the query --------------
scomand.connection.close();
}
}