a query [modified]
-
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 hav 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:48 Tuesday 20th February, 2007
-
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 hav 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:48 Tuesday 20th February, 2007
'all things is all right .I THINK U Assign n as date and here u declare string.so it might get error. 'string d = form1_.n; ' used like this datetime n = form1.n; '& u used from1 is the name of form right?
-
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 hav 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:48 Tuesday 20th February, 2007
I see three errors in your code. 1. You have declared the reference
form1_
as a reference to aForm
object, not aform1
object. Therefore you only have access to the members of the base class, none of the members of the inherited class. 2. You are creating a completely new instance ofform1
, that means that it's separate from the instance that already exists. This in turn means that then
member has not been set for that instance. 3. You are executing an insert query and expect it to return data. The result from an insert query is empty, so theExecuteScalar
method will return null. This will be converted toDateTime.MinValue
by theConvert.ToDateTime
call.--- single minded; short sighted; long gone;
-
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 hav 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:48 Tuesday 20th February, 2007
Take a look on it http://www.codeproject.com/useritems/pass\_data\_between\_forms.asp
Thanks and Regards Sandeep
-
'all things is all right .I THINK U Assign n as date and here u declare string.so it might get error. 'string d = form1_.n; ' used like this datetime n = form1.n; '& u used from1 is the name of form right?
-
Take a look on it http://www.codeproject.com/useritems/pass\_data\_between\_forms.asp
Thanks and Regards Sandeep
-
My Pleasure :)
Thanks and Regards Sandeep