I've an error like this 'loginpage.Loginform.dt' is a 'field' but is used like a 'type' [Resolved]

Posted by Sudheep.grandhe under C# on 10/12/2011 | Points: 10 | Views : 2817 | Status : [Member] | Replies : 6
Hi ,

I've an error like this.Please rectify my problem.please do the needful.
Error1:- 'loginpage.Loginform.dt' is a 'field' but is used like a 'type'
Error 2:-Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Best,
Sudheep.



Responses

Posted by: Ndebata on: 10/12/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
1.Error1 Remove word table from dt table= dac.loginform(uname, upassword);
dt = dac.loginform(uname, upassword); 

2.Error2 Open is a method write it like
con.Open();


Are you using visual studio? As these are some basic errors, I would suggest to learn c# programming syntax.
http://msdn.microsoft.com/en-us/vcsharp/aa336766


Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
These errors can be rectified after viewing what you have coded.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

what's the solution for my problem.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gausi on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
Provide your code to rectify errors ..

Regards,

Gaurav Singh
(gausi)

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Error1:-loginpage.Loginform.dt' is a 'field' but is used like a 'type'.I am underlined the error point.what ever it shows.Please do the neeful


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace loginpage
{
public partial class Loginform : Form
{
DataTable dt = new DataTable();
BEClass being = new BEClass();
DALClass dac = new DALClass();
public Loginform()
{


}


private void btn_login_Click(object sender, EventArgs e)
{
string uname = txt_username.Text;
string upassword = txt_password.Text;
if (txt_username.Text.Length != 0 && txt_password.Text.Length != 0)
{
dt table= dac.loginform(uname, upassword);
if (dt.Rows.Count > 0)
{
Homepage hp = new Homepage();
hp.Show();
this.Hide();
}
else
{
MessageBox.Show("Login Failed......", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
txt_username.Text = "";
txt_password.Text = "";
}
}
}


private void btn_reset_Click(object sender, EventArgs e)
{
txt_username.Text = "";
txt_password.Text = "";
}

private void Loginform_Load(object sender, EventArgs e)
{
txt_username.Focus();
}


}
}
Error 2:-Only assignment, call, increment, decrement, and new object expressions can be used as a statement.I am underlined the error point.what ever it shows.Please do the neeful
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data .SqlClient ;
using System.Data ;
using System.Configuration ;

namespace loginpage
{
public class DBConnection
{
public SqlConnection opencon()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["imapct services"].ConnectionString);
con.Open;
return con;
}





Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Error 2:-Only assignment, call, increment, decrement, and new object expressions can be used as a statement.I am underlined the error point.what ever it shows.Please do the neeful
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data .SqlClient ;
using System.Data ;
using System.Configuration ;

namespace loginpage
{
public class DBConnection
{
public SqlConnection opencon()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["imapct services"].ConnectionString);
con.Open;
return con;
}


Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response