protected void Button3_Click(object sender, EventArgs e)
{
String path = Server.MapPath("App_Data\\dnis2010.mdb");
String sqlQuery = "SELECT * FROM tableRegister WHERE SerialNo=@TextBox41";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + path);
OleDbCommand aCommand = new OleDbCommand(sqlQuery, aConnection);
aCommand.Parameters.AddWithValue("TextBox41", TextBox41.Text);
try
{
aConnection.Open();
OleDbDataReader aReader = aCommand.ExecuteReader();
if (!aReader.HasRows)
{
ClientScript.RegisterStartupScript(typeof(Page), "PopUpMsg", "<script>alert ('Data Cannot Be Found!');</script>");
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox40.Text = "";
TextBox8.Text = "";
TextBox9.Text = "";
TextBox10.Text = "";
TextBox11.Text = "";
TextBox12.Text = "";
TextBox13.Text = "";
TextBox14.Text = "";
TextBox15.Text = "";
TextBox16.Text = "";
TextBox17.Text = "";
TextBox18.Text = "";
TextBox19.Text = "";
TextBox20.Text = "";
TextBox21.Text = "";
TextBox22.Text = "";
TextBox23.Text = "";
TextBox24.Text = "";
TextBox25.Text = "";
TextBox26.Text = "";
TextBox27.Text = "";
TextBox28.Text = "";
TextBox29.Text = "";
TextBox31.Text = "";
TextBox32.Text = "";
TextBox33.Text = "";
TextBox34.Text = "";
TextBox35.Text = "";
TextBox36.Text = "";
TextBox37.Text = "";
TextBox38.Text = "";
TextBox39.Text = "";
}
else
{
while (aReader.Read())
{
TextBox1.Visible = true;
TextBox2.Visible = true;
TextBox3.Visible = true;
TextBox4.Visible = true;
TextBox5.Visible = true;
TextBox6.Visible = true;
TextBox40.Visible = true;
TextBox8.Visible = true;
TextBox9.Visible = true;
TextBox10.Visible = true;
TextBox11.Visible = true;
TextBox12.Visible = true;
TextBox13.Visible = true;
TextBox14.Visible = true;
TextBox15.Visible = true;
TextBox16.Visible = true;
TextBox17.Visible = true;
TextBox18.Visible = true;
TextBox19.Visible = true;
TextBox20.Visible = true;
TextBox21.Visible = true;
TextBox22.Visible = true;
TextBox23.Visible = true;
TextBox24.Visible = true;
TextBox25.Visible = true;
TextBox26.Visible = true;
TextBox27.Visible = true;
TextBox28.Visible = true;
TextBox29.Visible = true;
TextBox31.Visible = true;
TextBox32.Visible = true;
TextBox33.Visible = true;
TextBox34.Visible = true;
TextBox35.Visible = true;
TextBox36.Visible = true;
TextBox37.Visible = true;
TextBox38.Visible = true;
TextBox39.Visible = true;
TextBox1.Text = "StaffName:";
TextBox2.Text = "StaffID:";
TextBox3.Text = "Hostname:";
TextBox4.Text = "Department:";
TextBox5.Text = "Section:";
TextBox6.Text = "Extension:";
TextBox40.Text = "Type:";
TextBox8.Text = "IPAddressType:";
TextBox9.Text = "IPAddress:";
TextBox10.Text = "MacAddress:";
TextBox11.Text = "CPUBrand:";
TextBox12.Text = "CPUModel:";
TextBox13.Text = "Processor:";
TextBox14.Text = "HardDisk:";
TextBox15.Text = "HDType:";
TextBox16.Text = "RAM:";
TextBox17.Text = "RAMType:";
TextBox18.Text = "MonitorBrand:";
TextBox19.Text = "MonitorModel:";
TextBox20.Text = "SerialNo:";
TextBox21.Text = "MouseBrand:";
TextBox22.Text = "MouseModel:";
TextBox23.Text = "SerialNo:";
TextBox24.Text = "KeyboardBrand:";
TextBox25.Text = "KeyboardModel:";
TextBox26.Text = "SerialNo:";
TextBox27.Text = "CDPlayer:";
TextBox28.Text = "CDPlayerBrand:";
TextBox29.Text = "CDPlayerModel:";
TextBox31.Text = "CDPlayerType:";
TextBox32.Text = "Windows:";
TextBox33.Text = "Other:";
TextBox34.Text = "ProductKey:";
TextBox35.Text = "Microsoft Office:";
TextBox36.Text = "ProductKey:";
TextBox37.Text = "SoftwareName:";
TextBox38.Text = "LicenceNo:";
TextBox39.Text = "Remarks:";
TextBox1.Text = aReader["StaffName"].ToString();
TextBox2.Text = aReader["StaffID"].ToString();
TextBox3.Text = aReader["Hostname"].ToString();
TextBox4.Text = aReader["Department"].ToString();
TextBox5.Text = aReader["Section"].ToString();
TextBox6.Text = aReader["Extension"].ToString();
TextBox40.Text = aReader["Type"].ToString();
TextBox8.Text = aReader["IpAddType"].ToString();
TextBox9.Text = aReader["IpAdd"].ToString();
TextBox10.Text = aReader["MacAdd"].ToString();
TextBox11.Text = aReader["CpuBrand"].ToString();
TextBox12.Text = aReader["CpuModel"].ToString();
TextBox13.Text = aReader["Processor"].ToString();
TextBox14.Text = aReader["HardDisk"].ToString();
TextBox15.Text = aReader["HDType"].ToString();
TextBox16.Text = aReader["RAM"].ToString();
TextBox17.Text = aReader["RAMType"].ToString();
TextBox18.Text = aReader["MonBrand"].ToString();
TextBox19.Text = aReader["MonModel"].ToString();
TextBox20.Text = aReader["MonSerialNo"].ToString();
TextBox21.Text = aReader["MouBrand"].ToString();
TextBox22.Text = aReader["MouModel"].ToString();
TextBox23.Text = aReader["MouSerialNo"].ToString();
TextBox24.Text = aReader["KeybBrand"].ToString();
TextBox25.Text = aReader["KeybModel"].ToString();
TextBox26.Text = aReader["KeybSerialNo"].ToString();
TextBox27.Text = aReader["CdPlay"].ToString();
TextBox28.Text = aReader["CdPlayBrand"].ToString();
TextBox29.Text = aReader["CdPlayModel"].ToString();
TextBox31.Text = aReader["CdPlayType"].ToString();
TextBox32.Text = aReader["Windows"].ToString();
TextBox33.Text = aReader["Other"].ToString();
TextBox34.Text = aReader["WProdKey"].ToString();
TextBox35.Text = aReader["MS"].ToString();
TextBox36.Text = aReader["MSProdKey"].ToString();
TextBox37.Text = aReader["SoftwareName"].ToString();
TextBox38.Text = aReader["LicenceNo"].ToString();
TextBox39.Text = aReader["Remarks"].ToString();
}
}
aReader.Close();
aConnection.Close();
}
catch (Exception)
{
ClientScript.RegisterStartupScript(typeof(Page), "PopUpMsg", "<script>alert ('Failed!');</script>");
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
String path = Server.MapPath("App_Data\\dnis2010.mdb");
String sqlQuery = "UPDATE tableRegister SET StaffName=@TextBox1, StaffID=@TextBox2, [Hostname]=@TextBox3, [Department]=@TextBox4, [Section]=@TextBox5, [Extension]=@TextBox6, Type=@TextBox40, IpAddType=@TextBox8, IpAdd=@TextBox9, MacAdd=@TextBox10, CpuBrand=@TextBox11, CpuModel=@TextBox12, Processor=@TextBox13, HardDisk=@TextBox14, HDType=@TextBox15, RAM=@TextBox16, RAMType=@TextBox17, MonBrand=@TextBox18, MonModel=@TextBox19, MonSerialNo=@TextBox20, MouBrand=@TextBox21, MouModel=@TextBox22, MouSerialNo=@TextBox23, KeybBrand=@TextBox24, KeybModel=@TextBox25, KeybSerialNo=@TextBox26, CdPlay=@TextBox27, CdPlayBrand=@TextBox28, CdPlayModel=@TextBox29, CdPlayType=@TextBox31, Windows=@TextBox32, Other=@TextBox33, WProdKey=@TextBox34, MS=@TextBox35, MSProdKey=@TextBox36, SoftwareName=@TextBox37, LicenceNo=@TextBox38, Remarks=@TextBox39 WHERE SerialNo=@TextBox41";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + path);
OleDbCommand aCommand = new OleDbCommand(sqlQuery, aConnection);
aCommand.Parameters.AddWithValue("TextBox1", TextBox1.Text);
aCommand.Parameters.AddWithValue("TextBox2", TextBox2.Text);
aCommand.Parameters.AddWithValue("TextBox3", TextBox3.Text);
aCommand.Parameters.AddWithValue("TextBox4", TextBox4.Text);
aCommand.Parameters.AddWithValue("TextBox5", TextBox5.Text);
aCommand.Parameters.AddWithValue("TextBox6", TextBox6.Text);
aCommand.Parameters.AddWithValue("TextBox40", TextBox40.Text);
aCommand.Parameters.AddWithValue("TextBox8", TextBox8.Text);
aCommand.Parameters.AddWithValue("TextBox9", TextBox9.Text);
aCommand.Parameters.AddWithValue("TextBox10", TextBox10.Text);
aCommand.Parameters.AddWithValue("TextBox11", TextBox11.Text);
aCommand.Parameters.AddWithValue("TextBox12", TextBox12.Text);
aCommand.Parameters.AddWithValue("TextBox13", TextBox13.Text);
aCommand.Parameters.AddWithValue("TextBox14", TextBox14.Text);
aCommand.Parameters.AddWithValue("TextBox15", TextBox15.Text);
aCommand.Parameters.AddWithValue("TextBox16", TextBox16.Text);
aCommand.Parameters.AddWithValue("TextBox17", TextBox17.Text);
aCommand.Parameters.AddWithValue("TextBox18", TextBox18.Text);
aCommand.Parameters.AddWithValue("TextBox19", TextBox19.Text);
aCommand.Parameters.AddWithValue("TextBox20", TextBox20.Text);
aCommand.Parameters.AddWithValue("TextBox21", TextBox21.Text);
aCommand.Parameters.AddWithValue("TextBox22", TextBox22.Text);
aCommand.Parameters.AddWithValue("TextBox23", TextBox23.Text);
aCommand.Parameters.AddWithValue("TextBox24", TextBox24.Text);
aCommand.Parameters.AddWithValue("TextBox25", TextBox25.Text);
aCommand.Parameters.AddWithValue("TextBox26", TextBox26.Text);
aCommand.Parameters.AddWithValue("TextBox27", TextBox27.Text);
aCommand.Parameters.AddWithValue("TextBox28", TextBox28.Text);
aCommand.Parameters.AddWithValue("TextBox29", TextBox29.Text);
aCommand.Parameters.AddWithValue("TextBox31", TextBox31.Text);
aCommand.Parameters.AddWithValue("TextBox32", TextBox32.Text);
aCommand.Parameters.AddWithValue("TextBox33", TextBox33.Text);
aCommand.Parameters.AddWithValue("TextBox34", TextBox34.Text);
aCommand.Parameters.AddWithValue("TextBox35", TextBox35.Text);
aCommand.Parameters.AddWithValue("TextBox36", TextBox36.Text);
aCommand.Parameters.AddWithValue("TextBox37", TextBox37.Text);
aCommand.Parameters.AddWithValue("TextBox38", TextBox38.Text);
aCommand.Parameters.AddWithValue("TextBox39", TextBox39.Text);
try
{
aConnection.Open();
int row = aCommand.ExecuteNonQuery();
ClientScript.RegisterStartupScript(typeof(Page), "PopUpMsg", "<script>alert ('Record Has Been Updated!');</script>");
aConnection.Close();
}
catch (Exception)
{
ClientScript.RegisterStartupScript(typeof(Page), "PopUpMsg", "<script>alert ('Fail to Updated!');</script>");
}
}
Can anyone correct my coding here..i didn't know what wrong with my code..rely need help coz this is my final project..