Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi everybody,

 

The following code runs fine util the commented lines. The debugger halts and sends me a message saying that "custView is a variable and is being used as a method". Can anyone shed some light on this? Thank you very much.

 

Best regards,

 

JC :)

 

 

--------------------------------------------------------------------------

 

 

private void btnLogin_Click(object sender, EventArgs e)

{

System.Data.DataView custViewLogin = new System.Data.DataView(SASCRDataSet.tabUsers, "", "Login", System.Data.DataViewRowState.CurrentRows);

System.Data.DataView custViewPassword = new System.Data.DataView(SASCRDataSet.tabUsers,"", "Password", System.Data.DataViewRowState.CurrentRows);

 

int rowIndexLogin = custViewLogin.Find(this.txtUserName.Text);

int rowIndexPassword = custViewPassword.Find(this.txtPassword.Text);

 

if (rowIndexLogin == -1 || rowIndexPassword == -1)

{

MessageBox.Show("Usuário ou Senha inválida. \r" + "Por favor tente de novo. ", "Acesso negado ...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

this.txtPassword.Focus();

this.txtPassword.Text = "";

CTM = CTM + 1;

 

if (CTM == TRYMAX)

{

MessageBox.Show("Você usou o nº máximo de tentativas \r" + " de login e está sendo desconectado \r" + " por motivos de segurança! ", "Acesso bloqueado ...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

Application.Exit();

}

}

else

{

//---------------- This is where the problems starts---------------

this.UserRealName.Text = custViewLogin(rowIndexLogin)("UserRealName").ToString();

this.AccessRights.Text = custViewLogin(rowIndexLogin)("AccessRights").ToString();

//---------------- This is where the problems finishes---------------

 

Form frmMain = new frmMain();

frmMain.Show();

this.Hide();

}

}

Posted

Did you learn VB before C#? Try swapping the ( ) with [ ]:

this.UserRealName.Text = custViewLogin[rowIndexLogin]["UserRealName"].ToString();
this.AccessRights.Text = custViewLogin[rowIndexLogin]["AccessRights"].ToString();

( ) is used for indexers in VB but [ ] is the indexer in C#, similiar to C++.

Posted

Hi mskeel,

 

Yes, I did learn VB way before I started learning C#. How did you guess that? hehehe. Anyway, I'm getting to love C# more and more for it's a more robust language and seems to be processed a lot faster by my machine.

 

Thank you so much for your reply. I can't believe the solution was so simple... Just amazing! Now the code works just fine. Thanks a million!

 

Bye for now,

 

JC :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...