Click here to Skip to main content
15,910,130 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regular Expression Control Pin
Guffa27-May-06 5:14
Guffa27-May-06 5:14 
QuestionRe: Regular Expression Control Pin
NaNg1524127-May-06 5:35
NaNg1524127-May-06 5:35 
GeneralRe: Regular Expression Control Pin
Guffa27-May-06 7:16
Guffa27-May-06 7:16 
GeneralRe: Regular Expression Control Pin
NaNg1524127-May-06 7:28
NaNg1524127-May-06 7:28 
AnswerRe: Regular Expression Control Pin
Guffa27-May-06 8:35
Guffa27-May-06 8:35 
AnswerRe: Regular Expression Control Pin
Al Ortega27-May-06 6:12
Al Ortega27-May-06 6:12 
QuestionSql +Arraylist + Datagridview Pin
JelleM27-May-06 4:09
JelleM27-May-06 4:09 
AnswerRe: Sql +Arraylist + Datagridview Pin
Colin Angus Mackay27-May-06 6:09
Colin Angus Mackay27-May-06 6:09 
JelleM wrote:
I don't really think the code is 100% ok, but can somebody help?


I've annotated your code with what it is doing.

// Not enough context to determine what this line does.
bill.Rows.Clear();
 
// Create a parameterised SQL Command
SqlCommand myCommand = new SqlCommand("SELECT * FROM orders WHERE date = @date", connect);
myCommand.Parameters.AddWithValue("@date", DateTime.Parse(listOrders.Text.ToString().Substring(0, 19)));
 
// Exectute the query
SqlDataReader myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
    // Assign amounts and products the results of the query
    amounts = myReader["amount"].ToString();
    products = myReader["productid"].ToString();
}
// Close the query - NOTE: If there is more than one row returned from the query all but
// the last row will have been lost by this point.
myReader.Close();
 
// These two lines are redundant - they do nothing useful.
string[] product = new string[products.Split(' ').Length];
string[] amount = new string[amounts.Split(' ').Length];
 
// If there were rows returned from the query then split the data up on a space character.
// If there were no rows returned from the query then products and amounts will be null
// and the code will fail.
product = products.Split(' ');
amount = amounts.Split(' ');

// Loop over the products array 
for (int i = 0; i <= product.Length; i++)
{
    // Not enough context to say what this line does.
    bill.Rows.Add(amount[i], product[i], 1, 2);
}


Does this help you see what your code is doing?


"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)

My: Website | Blog
GeneralRe: Sql +Arraylist + Datagridview Pin
JelleM27-May-06 10:45
JelleM27-May-06 10:45 
QuestionAnother problem with two forms [modified] Pin
mariuszfryta27-May-06 3:54
mariuszfryta27-May-06 3:54 
AnswerRe: Another problem with two forms [modified] Pin
Sean8927-May-06 4:35
Sean8927-May-06 4:35 
GeneralRe: Another problem with two forms [modified] Pin
mariuszfryta27-May-06 4:52
mariuszfryta27-May-06 4:52 
GeneralRe: Another problem with two forms [modified] Pin
Sean8927-May-06 6:33
Sean8927-May-06 6:33 
GeneralRe: Another problem with two forms [modified] Pin
mariuszfryta27-May-06 7:08
mariuszfryta27-May-06 7:08 
QuestionHow can I close one form Pin
mariuszfryta27-May-06 3:41
mariuszfryta27-May-06 3:41 
AnswerRe: How can I close one form Pin
Sean8927-May-06 3:48
Sean8927-May-06 3:48 
GeneralRe: How can I close one form Pin
mariuszfryta27-May-06 3:49
mariuszfryta27-May-06 3:49 
AnswerRe: How can I close one form Pin
Stefan Troschuetz27-May-06 3:48
Stefan Troschuetz27-May-06 3:48 
QuestionHow do I use line endings in a class? Pin
WCup27-May-06 3:23
WCup27-May-06 3:23 
GeneralRe: How do I use line endings in a class? Pin
Guffa27-May-06 3:57
Guffa27-May-06 3:57 
GeneralRe: How do I use line endings in a class? Pin
WCup27-May-06 4:20
WCup27-May-06 4:20 
AnswerRe: How do I use line endings in a class? Pin
Guffa27-May-06 5:17
Guffa27-May-06 5:17 
QuestionComboBox in C# Pin
AbdulRahmanOfpk27-May-06 3:00
AbdulRahmanOfpk27-May-06 3:00 
AnswerRe: ComboBox in C# Pin
MoustafaS27-May-06 3:29
MoustafaS27-May-06 3:29 
QuestionHow can I do a simple alarm clock in c# Pin
mariuszfryta27-May-06 1:27
mariuszfryta27-May-06 1:27 

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.