Click here to Skip to main content
15,893,814 members
Home / Discussions / C#
   

C#

 
QuestionSet & Get in a C# Class Pin
allan.gagnon15-Feb-07 3:57
allan.gagnon15-Feb-07 3:57 
AnswerRe: Set & Get in a C# Class Pin
Not Active15-Feb-07 4:07
mentorNot Active15-Feb-07 4:07 
GeneralRe: Set & Get in a C# Class Pin
Colin Angus Mackay15-Feb-07 4:13
Colin Angus Mackay15-Feb-07 4:13 
GeneralRe: Set & Get in a C# Class Pin
allan.gagnon15-Feb-07 4:32
allan.gagnon15-Feb-07 4:32 
GeneralRe: Set & Get in a C# Class Pin
Not Active15-Feb-07 4:33
mentorNot Active15-Feb-07 4:33 
AnswerRe: Set & Get in a C# Class Pin
Colin Angus Mackay15-Feb-07 4:12
Colin Angus Mackay15-Feb-07 4:12 
GeneralRe: Set & Get in a C# Class Pin
allan.gagnon15-Feb-07 4:26
allan.gagnon15-Feb-07 4:26 
GeneralRe: Set & Get in a C# Class Pin
allan.gagnon15-Feb-07 4:44
allan.gagnon15-Feb-07 4:44 
Ok Thank you for the help so far this time I will try to explain the question better. I guess I am a newbie at c# and a newbie at asking questions about c#.

Here is question number 2:

I have wrote this code

public static void Login(String LoginBox)
{
string strConn, strSQL;
bool LoginSucceeded;
strConn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\admin\My Documents\Visual Studio 2005\Projects\GasCabinetSimulator\GasCabinetSimulator\GasCabinet.mdf;Integrated Security=True;User Instance=True";
strSQL = "SELECT UserID, PassWord, IsLoggedIn FROM tblLogin";
using (SqlConnection cn = new SqlConnection(strConn))
{
try
{
cn.Open();
}
catch (SqlException ex)
{
MessageBox.Show("Connect Attempt Failed");
MessageBox.Show(ex.Message);
return;
}
using (SqlCommand cmd = new SqlCommand(strSQL, cn))
{
try
{
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
if (LoginBox == rdr["PassWord"].ToString())
{
MessageBox.Show("Login successful","Login Success",
MessageBoxButtons.OK,MessageBoxIcon.Information);
MessageBox.Show(rdr["IsLoggedIn"].ToString());
rdr["IsLoggedIn"] = true;
}

rdr.Close();
}
}
catch (SqlException ex)
{
MessageBox.Show("Query failed");
MessageBox.Show(ex.Message);
return;
}

}

cn.Close();

However I am getting this error message when I build my project:

Error 1 Property or indexer 'System.Data.Common.DbDataReader.this[string]' cannot be assigned to -- it is read only C:\Documents and Settings\admin\My Documents\Visual Studio 2005\Projects\GasCabinetSimulator\GasCabinetSimulator\ClassLogin.cs 46 37 GasCabinetSimulator

This line is the error: rdr["IsLoggedIn"] = true;

Where am i going wrong?

Thank you again for all your help!!

Allan F. Gagnon

GeneralRe: Set & Get in a C# Class Pin
Colin Angus Mackay15-Feb-07 5:32
Colin Angus Mackay15-Feb-07 5:32 
GeneralRe: Set & Get in a C# Class Pin
allan.gagnon16-Feb-07 3:19
allan.gagnon16-Feb-07 3:19 
Questionselecting image Pin
HexaDeveloper15-Feb-07 3:46
HexaDeveloper15-Feb-07 3:46 
QuestionHow can SqlDataReader implement IDisposable in .NET v1 when the Dispose method is private??!! Pin
cufc15-Feb-07 3:29
cufc15-Feb-07 3:29 
AnswerRe: How can SqlDataReader implement IDisposable in .NET v1 when the Dispose method is private??!! Pin
m@u15-Feb-07 3:45
m@u15-Feb-07 3:45 
GeneralRe: How can SqlDataReader implement IDisposable in .NET v1 when the Dispose method is private??!! Pin
cufc16-Feb-07 1:20
cufc16-Feb-07 1:20 
GeneralRe: How can SqlDataReader implement IDisposable in .NET v1 when the Dispose method is private??!! Pin
m@u16-Feb-07 2:26
m@u16-Feb-07 2:26 
QuestionI want to make a form as mirror for desktop Pin
waleed9915-Feb-07 3:22
waleed9915-Feb-07 3:22 
AnswerRe: I want to make a form as mirror for desktop Pin
Niiiissssshhhhhuuuuu15-Feb-07 3:33
Niiiissssshhhhhuuuuu15-Feb-07 3:33 
GeneralRe: I want to make a form as mirror for desktop Pin
waleed9915-Feb-07 5:10
waleed9915-Feb-07 5:10 
GeneralRe: I want to make a form as mirror for desktop Pin
Niiiissssshhhhhuuuuu15-Feb-07 17:47
Niiiissssshhhhhuuuuu15-Feb-07 17:47 
Questionweb based data analysis tool for stocks Pin
tota123415-Feb-07 2:59
tota123415-Feb-07 2:59 
AnswerRe: web based data analysis tool for stocks Pin
alex.almeida15-Feb-07 7:56
alex.almeida15-Feb-07 7:56 
GeneralRe: web based data analysis tool for stocks Pin
tota123415-Feb-07 8:20
tota123415-Feb-07 8:20 
GeneralRe: web based data analysis tool for stocks Pin
alex.almeida15-Feb-07 8:37
alex.almeida15-Feb-07 8:37 
GeneralRe: web based data analysis tool for stocks Pin
tota123415-Feb-07 9:08
tota123415-Feb-07 9:08 
GeneralRe: web based data analysis tool for stocks Pin
alex.almeida16-Feb-07 0:52
alex.almeida16-Feb-07 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.