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

C#

 
AnswerRe: how to work with an opened text file in list box? Pin
Luc Pattyn7-Feb-09 9:09
sitebuilderLuc Pattyn7-Feb-09 9:09 
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 
I have a windows form program that needs to check records to make sure they are valid, and if so will append the description to the record. In an effort to reduce the impact this has on our database server, I'm loading everything I need into memory using a DataAdapter and filling a DataTable. Now that I have my table filled, I want to go through each item number and search the table to see if it exists...that's where I seem to be stuck. I'm open to other ideas if this isn't the best method. I've considered arraylists, dictionarys, even jagged arrays but couldn't figure out how to iterate through the DataReader to fill the arrays which is why I fell back to the DataTable. Here's what I have so far:

string[] AllContents = File.ReadAllLines(scanner_number);

DataTable dt1 = inv1.get_part_information();

foreach (string s in AllContents)
{
    string[] splitup = s.Split(new char[]{}, StringSplitOptions.RemoveEmptyEntries);

     <big>DataRow[] row = dt1.Select("'I$PN' = 'CA-106-77'");</big>
     string test1 = row[0].ToString();
     string test2 = row[1].ToString();

    splitup[2] = splitup[2].Remove(8);
    splitup[2] = splitup[2].Substring(4, 2) + "/" + splitup[2].Substring(6, 2) + "/" + splitup[2].Substring(0, 4);
    textBox1.Text += "...." + s + Environment.NewLine;
}


now, I've hard coded the select string because I'm just trying to figure out how to get the Expression correct. The system appears to find the column correctly, and that is a verified value, however it always fails on the string test line...and watching the datarow in visual studio shows that there is no data in the row.

I've searched around online and did see one forum suggest trying something like this considering I am only ever expecting one row to be returned:
DataRow row = dt1.Select("'I$PN' = 'CA-106-77'")[0]

but this gives me the indexoutofrange exception.

"You're damned if you do, and you're damned if you dont" - Bart Simpson

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 
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 

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.