a query [modified]
-
private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs and i need to write it there only on 'logout_click'. Now i want to use this 'int n' in a function in form2.cs of same project: funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs. How can i declare this 'int n' of form1 in form2? How can i do this? thanx. nekshan. -- modified at 1:57 Tuesday 20th February, 2007
-
private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs and i need to write it there only on 'logout_click'. Now i want to use this 'int n' in a function in form2.cs of same project: funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs. How can i declare this 'int n' of form1 in form2? How can i do this? thanx. nekshan. -- modified at 1:57 Tuesday 20th February, 2007
'form1 ' define this n globally on top of form1 Public n As Integer ' form2 ' create objec to from1 in from2 Dim f1 As New Form1 ' used like string s = f1.n 'this declaration is vb convert it to c# ok.
-
private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs and i need to write it there only on 'logout_click'. Now i want to use this 'int n' in a function in form2.cs of same project: funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs. How can i declare this 'int n' of form1 in form2? How can i do this? thanx. nekshan. -- modified at 1:57 Tuesday 20th February, 2007
Hi Use Query string or you can put this varaible in the session and get it from the session on next page
Thanks and Regards Sandeep
-
private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs and i need to write it there only on 'logout_click'. Now i want to use this 'int n' in a function in form2.cs of same project: funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs. How can i declare this 'int n' of form1 in form2? How can i do this? thanx. nekshan. -- modified at 1:57 Tuesday 20th February, 2007
-
Hi Use Query string or you can put this varaible in the session and get it from the session on next page
Thanks and Regards Sandeep
-
Store the value in a hidden html field. And user server.transfer to go to other form and in form2 use the request object to get the value of hidden field from form1
Nana
-
session? i m doing windows programming. can i use session in windows programming? i dont think so.. if can... how? Thank You. nekshan.
Sorry Boss You should mension that
Thanks and Regards Sandeep
-
ya wind prog code is sent u
-
'form1 ' define this n globally on top of form1 Public n As Integer ' form2 ' create objec to from1 in from2 Dim f1 As New Form1 ' used like string s = f1.n 'this declaration is vb convert it to c# ok.
In form1,i defined it like : namespace WindowsApplication1 { public partial class form1 : Form { public DateTime n; SqlConnection conn = new SqlConnection("Data Source=PROGRAMER;Initial Catalog=...."); ..... } In form2,i made object of form1: System.Windows.Forms.Form form1_ = new form1(); string d = form1_.n; -- BUT it is giving error on 'n' here, 'n' doesnot come on click of'.' after form1_ I have used it like this in form1: private void button1_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); n = Convert.ToDateTime(cm.ExecuteScalar()); } Is my global declaration of 'n' still not proper? Thank You. Nekshan. -- modified at 2:51 Tuesday 20th February, 2007
-
private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs and i need to write it there only on 'logout_click'. Now i want to use this 'int n' in a function in form2.cs of same project: funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs. How can i declare this 'int n' of form1 in form2? How can i do this? thanx. nekshan. -- modified at 1:57 Tuesday 20th February, 2007
-
private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs and i need to write it there only on 'logout_click'. Now i want to use this 'int n' in a function in form2.cs of same project: funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n',if i write the above code, as 'n' is not declared in form2.cs. How can i declare this 'int n' of form1 in form2? How can i do this? thanx. nekshan. -- modified at 1:57 Tuesday 20th February, 2007
you can set the variable up as a public static property of some class. This isn't the best technique as it is very similar to having a global variable. You could set a property on form2 or pass the value of n into form2 in its constructor, I would rather do one of these depending on how your application is coded. Russell