Hi,
 
It's not a big problem friend. You have defined SqlConnection con; SqlTransaction trans; SqlDataAdapter da after the namespace. Because of that you are getting this problem. Namespace is a collection of classes so you can't declare variables inside that so try to declare your variables inside some class or methods. You can easily remove first problem.
 
Second problem i will let you know if i can find the solution.
 
Rajendra

Serkan Yuzbasioglu <[EMAIL PROTECTED]> wrote:

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.


Do you Yahoo!?
Send holiday email and support a worthy cause. Do good.
Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to