Click here to Skip to main content
15,891,951 members
Home / Discussions / C#
   

C#

 
QuestionRe: how to work with an opened text file in list box? Pin
pcsience8-Feb-09 8:53
pcsience8-Feb-09 8:53 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn8-Feb-09 9:03
sitebuilderLuc Pattyn8-Feb-09 9:03 
GeneralRe: how to work with an opened text file in list box? Pin
pcsience8-Feb-09 9:42
pcsience8-Feb-09 9:42 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn8-Feb-09 10:04
sitebuilderLuc Pattyn8-Feb-09 10:04 
QuestionRe: how to work with an opened text file in list box? Pin
pcsience9-Feb-09 9:08
pcsience9-Feb-09 9:08 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn9-Feb-09 9:19
sitebuilderLuc Pattyn9-Feb-09 9:19 
QuestionCannot figure out how to get the row I need in a datatable Pin
compninja256-Feb-09 9:49
compninja256-Feb-09 9:49 
AnswerRe: Cannot figure out how to get the row I need in a datatable Pin
Luc Pattyn6-Feb-09 10:03
sitebuilderLuc Pattyn6-Feb-09 10:03 
Hi,

I'm no DB specialist but did some, so I'll try and help:

1.

itmaster21 wrote:
DataRow row = dt1.Select("'I$PN' = 'CA-106-77'")[0]


is bound to fail if no data is found: you can't access row 0 when there are no rows at all.


itmaster21 wrote:
DataRow[] row = dt1.Select("'I$PN' = 'CA-106-77'");


seems OK with two comments:
1. it is unfortunate to have special characters in field names, without the dollar sign, the field name should not need single quotes, it could look like DataRow[] row = dt1.Select("name = 'CA-106-77'");
2. you are confusing yourself by calling the result row, it really should be rows indicating you may obtain 0, 1 or any number of rows.



itmaster21 wrote:
string test1 = row[0].ToString();
string test2 = row[1].ToString();


is unsafe again: the number of rows returned can be less than 2, in which case one or both index operations would fail with an IndexOutOfRangeException. You need to program more defensively.

itmaster21 wrote:
splitup[2] = splitup[2].Remove(8);


Dito. What guarantee do you have splitup holds 3 or more elements?
At the very least, you should put everything in a try-catch construct, and show the entire exception
if and when you get it (that is Exception.ToString, not just Exception.Message).

Hope this helps.

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


GeneralRe: Cannot figure out how to get the row I need in a datatable Pin
compninja256-Feb-09 10:19
compninja256-Feb-09 10:19 
GeneralRe: Cannot figure out how to get the row I need in a datatable Pin
compninja259-Feb-09 3:04
compninja259-Feb-09 3:04 
AnswerRe: Cannot figure out how to get the row I need in a datatable Pin
Ennis Ray Lynch, Jr.6-Feb-09 10:48
Ennis Ray Lynch, Jr.6-Feb-09 10:48 
GeneralRe: Cannot figure out how to get the row I need in a datatable Pin
compninja259-Feb-09 2:13
compninja259-Feb-09 2:13 
GeneralRe: Cannot figure out how to get the row I need in a datatable Pin
Ennis Ray Lynch, Jr.9-Feb-09 2:42
Ennis Ray Lynch, Jr.9-Feb-09 2:42 
GeneralRe: Cannot figure out how to get the row I need in a datatable [modified] Pin
compninja259-Feb-09 2:52
compninja259-Feb-09 2:52 
QuestionIs using a User Control Embedded Class a good practice? Pin
MacSpudster6-Feb-09 9:05
professionalMacSpudster6-Feb-09 9:05 
AnswerNot really the place for this question Pin
Pete O'Hanlon6-Feb-09 11:26
mvePete O'Hanlon6-Feb-09 11:26 
GeneralRe: Not really the place for this question Pin
MacSpudster9-Feb-09 8:34
professionalMacSpudster9-Feb-09 8:34 
Questiongenerating a class from an xsd at runtime? Pin
orinoco776-Feb-09 5:52
orinoco776-Feb-09 5:52 
AnswerRe: generating a class from an xsd at runtime? Pin
Ennis Ray Lynch, Jr.6-Feb-09 7:17
Ennis Ray Lynch, Jr.6-Feb-09 7:17 
QuestionReading the Caption(Title) of another Window Pin
SimpleData6-Feb-09 5:26
SimpleData6-Feb-09 5:26 
AnswerRe: Reading the Caption(Title) of another Window Pin
0x3c06-Feb-09 5:34
0x3c06-Feb-09 5:34 
AnswerRe: Reading the Caption(Title) of another Window Pin
Giorgi Dalakishvili6-Feb-09 5:48
mentorGiorgi Dalakishvili6-Feb-09 5:48 
QuestionGet SelectedListViewItemCollection threadsafe [modified] Pin
Tobesucht6-Feb-09 4:07
Tobesucht6-Feb-09 4:07 
AnswerRe: Get SelectedListViewItemCollection threadsafe Pin
Tobesucht8-Feb-09 21:11
Tobesucht8-Feb-09 21:11 
QuestionSystem.Data.SqlClient.SqlClientpermission,System, publickey token='......' failed exception Pin
praveenvkumarv6-Feb-09 3:53
praveenvkumarv6-Feb-09 3:53 

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.