Can anyone help me in that program that i couldnt solve the mistakes in codes?
Regards
--------------------------------------------------------------------
using System.Data.SqlClient;
namespace uyelik_kaydi
{
SqlConnection con; /*HERE IS THE PROBLEM.... "A namespace does not directly contain members such as fields or methods" */
SqlTransaction trans;
SqlDataAdapter da;
private void btnBegin_Click(object sender,System.EventArgs e)
{
if(con.State==ConnnectionState.Closed)
{
con.Open();
}
trans=con.BeginTransaction(IsolationLevel.ReadUncommitted);
}
private void Form1_Load(object sender,System.EventArgs e)
{
con=new SqlConnection("datasource=CHN;database=master;integrated security=SSPI");
}
private void btnCommit_Click(object sender,System.EventArgs e)
{
trans.Commit();
}
private void btnRollback_Click(object sender,System.EventArgs e)
{
trans.Rollback();
}
private void btnBak_Click(object sender,System.EventArgs e)
{
sqlCommand cmdBak=new SqlCommand("SELECT*FROM Personol",con),
cmdBak.Transaction=trans;
da=new SqlDataAdapter(cmdBak);
DataTable dt=new DataTable();
da.Fill(dt);
dataGrid1.DataSource=dt;
}
private void btnEkle_Click(object sender,System.EventArgs e)
{
SqlCommand cmdGir=newSqlCommand("INSERT INTO Personel(ISIM,SOYISIM)VALUES("'+txtIsim.Text+"',"'txtSoyisim.Text+"')",con); /*HERE IS THE PROBLEM I COULDN�T UNDERSTAND�.. �Newline in constant� */
cmdGir.Transcation=trans;
int sonuc=cmdGir.ExecuteNonQuery();
MessageBox.Show(sonuc+"SATIR GIRILDI");
}
private void btnGuncelle_Click(object sender,System.EventArgs e)
{
SqlCommand cmdGuncelle=new SqlCommand("UPTADE Personol SET ISIM="'+txtIsim.Text+"',
SOYISIM="'+txtSoyisim.Text+"'WHEREID="+txtID.Text,con); /*HERE IS THE PROBLEM I COULDN�T UNDERSTAND�.. �Newline in constant� */
cmdGuncelle.Transaction=trans;
int sonuc=cmdGuncelle.ExecuteNonQuery();
MessageBox.Show(sonuc+"SATIR GUNCELLENDI");
}
private void btnBakID_Click(object sender,System.EventArgs e)
{
SqlCommand cmd=newSqlCommand("SELECT ISIM,SOYISIM FROM PersonelWHERE ID="+txtID.Text,con);
cmd.Transaction=trans;
da=newSqlDataAdapter(cmd);
DataTable dt=new DataTable();
da.Fill(dt);
dataGrid1.DataSource=dt;
}
}
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Microsofts_C_Sharp/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
