Click here to Skip to main content
15,914,360 members
Home / Discussions / C#
   

C#

 
QuestionAbstract class with no body Pin
NarVish8-May-08 23:56
NarVish8-May-08 23:56 
AnswerRe: Abstract class with no body Pin
John Ad9-May-08 0:27
John Ad9-May-08 0:27 
AnswerRe: Abstract class with no body Pin
PIEBALDconsult9-May-08 7:41
mvePIEBALDconsult9-May-08 7:41 
Questionmeta data for assembly Pin
George_George8-May-08 23:52
George_George8-May-08 23:52 
AnswerRe: meta data for assembly Pin
Christian Graus9-May-08 1:03
protectorChristian Graus9-May-08 1:03 
GeneralRe: meta data for assembly Pin
George_George10-May-08 21:05
George_George10-May-08 21:05 
QuestionDebug C#-Code called from C++ Application via COM-Wrapper Pin
ieaeitsch8-May-08 23:19
ieaeitsch8-May-08 23:19 
QuestionArray Size Query Pin
AnthonyW8-May-08 23:17
AnthonyW8-May-08 23:17 
I wish to build a multi sized array to read data from a specific source (in this case an SQLDataReader). The following code DOES work however it seems fairly drawn out and I'm certain that it could be done in less code. I'm fairly new to C# hence why I think my way of doing it possibly isn't the most efficient.
Without giving the array a size I get a compiling error and thus have to have two while loops to give the array a size. Is there a better way to do this?

Many thanks.. Ant

MSSQLConn.Open();
SqlCommand MSSQLCommandSelect = new SqlCommand();
MSSQLCommandSelect.CommandText = "SELECT TrackingID FROM Tracking WHERE " + FieldToSearch + " = " + DataToSearch;
MSSQLCommandSelect.Connection = MSSQLConn;
SqlDataReader reader = MSSQLCommandSelect.ExecuteReader();

int[] TrackingIDs;
int i = 0;
while (reader.Read() == true)
{
    i++;
}
reader.Close();

reader = null;
reader = MSSQLCommandSelect.ExecuteReader();
TrackingIDs = new int[i];
i = 0;
TrackingIDs[0] = -1;
while (reader.Read() == true)
{
    TrackingIDs[i] = (int)reader[0];
    i++;
}
reader.Close();
MSSQLConn.Close();
return TrackingIDs;

AnswerRe: Array Size Query Pin
Coding C#8-May-08 23:23
Coding C#8-May-08 23:23 
AnswerRe: Array Size Query Pin
phannon868-May-08 23:25
professionalphannon868-May-08 23:25 
GeneralRe: Array Size Query Pin
AnthonyW8-May-08 23:35
AnthonyW8-May-08 23:35 
QuestionReading a property from list of an object from given index Pin
Nais8-May-08 23:07
Nais8-May-08 23:07 
Questionhow to get text within <iframe> in .net with c#</iframe> Pin
sugunavathysubramanian8-May-08 22:56
sugunavathysubramanian8-May-08 22:56 
AnswerRe: how to get text within in .net with c# Pin
phannon868-May-08 23:00
professionalphannon868-May-08 23:00 
GeneralRe: how to get text within in .net with c# Pin
sugunavathysubramanian8-May-08 23:07
sugunavathysubramanian8-May-08 23:07 
QuestionDesign display problem in c# Pin
selvarajanlatha8-May-08 22:40
selvarajanlatha8-May-08 22:40 
AnswerRe: Design display problem in c# Pin
Gareth H8-May-08 22:50
Gareth H8-May-08 22:50 
QuestionHow to set search provider to my browser in c#.net ? Pin
Thirukkumaran8-May-08 21:50
Thirukkumaran8-May-08 21:50 
AnswerRe: How to set search provider to my browser in c#.net ? Pin
Vikram A Punathambekar8-May-08 22:25
Vikram A Punathambekar8-May-08 22:25 
QuestionRemoting Exception...Am i solving it correct.......? Pin
Siddharth Rastogi8-May-08 21:03
Siddharth Rastogi8-May-08 21:03 
AnswerRe: ASP.NET Question Pin
Gareth H8-May-08 22:48
Gareth H8-May-08 22:48 
GeneralRe: ASP.NET Question Pin
Siddharth Rastogi8-May-08 22:53
Siddharth Rastogi8-May-08 22:53 
QuestionCrystal report viewer toolbar Print button event PinPopular
AbhijeetB8-May-08 21:01
AbhijeetB8-May-08 21:01 
Questioncan anyone help me out? Pin
cristi_alonso8-May-08 20:54
cristi_alonso8-May-08 20:54 
QuestionReportViewer Pin
_str_618-May-08 19:55
_str_618-May-08 19:55 

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.