Click here to Skip to main content
15,921,226 members
Home / Discussions / C#
   

C#

 
QuestionSerialization / Deserialization Problem Pin
Sautin.net7-Nov-07 6:37
Sautin.net7-Nov-07 6:37 
AnswerRe: Serialization / Deserialization Problem Pin
led mike7-Nov-07 6:50
led mike7-Nov-07 6:50 
GeneralRe: Serialization / Deserialization Problem Pin
Sautin.net7-Nov-07 6:58
Sautin.net7-Nov-07 6:58 
GeneralRe: Serialization / Deserialization Problem Pin
led mike7-Nov-07 8:06
led mike7-Nov-07 8:06 
AnswerRe: Serialization / Deserialization Problem Pin
Giorgi Dalakishvili7-Nov-07 6:56
mentorGiorgi Dalakishvili7-Nov-07 6:56 
GeneralRe: Serialization / Deserialization Problem Pin
Sautin.net7-Nov-07 8:01
Sautin.net7-Nov-07 8:01 
GeneralRe: Serialization / Deserialization Problem Pin
Giorgi Dalakishvili7-Nov-07 8:07
mentorGiorgi Dalakishvili7-Nov-07 8:07 
QuestionNewbie Problem Pin
kingletas7-Nov-07 5:29
kingletas7-Nov-07 5:29 
Hey all,

I want to update single columns on a table. I know how to do it in SQL itself but i want to update it from inside a c# code, where i have no experience at all, i mean working with databases from C#. So far i know how to read the data from an specific table. However this code:

try
{
SqlCon = new SqlConnection(ConnString);
SqlCmd = new SqlCommand();
SqlCmd.CommandText = "select votos_recibidos from party where Name_Party ='" + party + "'";
SqlCmd.Connection = SqlCon;
SqlCon.Open();
dataReader = SqlCmd.ExecuteReader();
//reading the current value of the column
int temp = dataReader.GetInt32(0);//this is where the exception occurs
temp = temp+1;//add 1 to the current value

SqlCmd.CommandText = "update Party set Votos_recibidos ="+temp+"where Name_Party ='"+party+"'";
dataReader = SqlCmd.ExecuteReader();

dataReader.Close();
SqlCon.Close();

}
catch (SqlException SqE)
{
System.Windows.Forms.MessageBox.Show(SqE.Message);

}


But this gives me the next exception:

"Invalid attempt to read when no data is present."

But that column takes not null and it has a value of 0 first but then i manually changed to 1, just in case.
Any tip of what i am doing wrong because i know the statement has no problem itself. Maybe i am just doing it wrong in c#.

thanks,



Luis E Tineo S

AnswerRe: Newbie Problem Pin
snorkie7-Nov-07 5:38
professionalsnorkie7-Nov-07 5:38 
GeneralRe: Newbie Problem Pin
kingletas7-Nov-07 6:37
kingletas7-Nov-07 6:37 
AnswerRe: Newbie Problem Pin
Michael Sync7-Nov-07 5:52
Michael Sync7-Nov-07 5:52 
GeneralRe: Newbie Problem Pin
kingletas7-Nov-07 6:44
kingletas7-Nov-07 6:44 
GeneralRe: Newbie Problem Pin
Michael Sync7-Nov-07 7:01
Michael Sync7-Nov-07 7:01 
GeneralRe: Newbie Problem Pin
kingletas7-Nov-07 8:14
kingletas7-Nov-07 8:14 
QuestionSystem.Net settings [modified] Pin
Stevo Z7-Nov-07 5:10
Stevo Z7-Nov-07 5:10 
AnswerRe: System.Net settings Pin
Judah Gabriel Himango7-Nov-07 7:44
sponsorJudah Gabriel Himango7-Nov-07 7:44 
GeneralRe: System.Net settings Pin
Stevo Z7-Nov-07 21:29
Stevo Z7-Nov-07 21:29 
JokeRe: System.Net settings Pin
Judah Gabriel Himango8-Nov-07 4:17
sponsorJudah Gabriel Himango8-Nov-07 4:17 
QuestionMDI Parent & Child Form Pin
tantja7-Nov-07 4:52
tantja7-Nov-07 4:52 
AnswerRe: MDI Parent & Child Form Pin
Matthew Butler7-Nov-07 5:43
Matthew Butler7-Nov-07 5:43 
GeneralRe: MDI Parent & Child Form Pin
tantja7-Nov-07 5:54
tantja7-Nov-07 5:54 
GeneralRe: MDI Parent & Child Form Pin
Matthew Butler7-Nov-07 6:32
Matthew Butler7-Nov-07 6:32 
Questioni need helllllllllllllllllllllllllllllllllllllp Pin
Mohammed Elkholy7-Nov-07 4:42
Mohammed Elkholy7-Nov-07 4:42 
AnswerRe: i need helllllllllllllllllllllllllllllllllllllp Pin
Pete O'Hanlon7-Nov-07 4:48
mvePete O'Hanlon7-Nov-07 4:48 
GeneralRe: i need helllllllllllllllllllllllllllllllllllllp Pin
Mohammed Elkholy7-Nov-07 4:58
Mohammed Elkholy7-Nov-07 4:58 

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.