lighthead 55 Junior Poster in Training

1) I have attached a small solution to make it clear.
2) I apologize for a small mistake on my part, I missed the single quotes in my earlier posts.

System.Data.SqlClient.SqlCommand cmd = new SqlCommand("INSERT INTO Table_1 (ScreenShotNumber, TestScriptID, StepNumber, TesterInitials, Date, DocumentNumber) "
 +"VALUES ( '" + ScreenShotNumber + "' , '" +  TestScriptID +"' , '"  + TesterInitials + "' , '" TesterInitials + "' ,  '" +  DocumentNumber "') ", sqlConnection1);

corrected

lighthead 55 Junior Poster in Training

Yes, I did.
In

System.Data.SqlClient.SqlCommand cmd = new SqlCommand("INSERT INTO Table_1 (ScreenShotNumber, TestScriptID, StepNumber, TesterInitials, Date, DocumentNumber) "
 +"VALUES ( " + ScreenShotNumber + " , " +  TestScriptID +" , "  + TesterInitials + " , " TesterInitials + " ,  " +  DocumentNumber ") ", sqlConnection1);

The terms ScreenShotNumber ,TestScriptID ,.... are not parameters they are the variables whose value is taken to create the query string. These values are necessary.

If you are still not clear, look at a few examples on the net. :)

lighthead 55 Junior Poster in Training
UPDATE tablename set columnname = REPLACE(coulmnname,'old','new')
where columnname like '%old%'

Something like this...perhaps

lighthead 55 Junior Poster in Training

ScreenShotNumber is a variable you should have defined as you used it in your first post.

cmd.Parameters.Add("@ScreenShotNumber", SqlDbType.NVarChar, 50, "ScreenShotNumber");
cmd.Parameters.Add("@TestScriptID", SqlDbType.NVarChar, 50, "TestScriptID");
cmd.Parameters.Add("@StepNumber", SqlDbType.NVarChar, 50, "StepNumber");

ScreenShotNumber is the value of ScreenShotNumber(column name) that you want to insert.

lighthead 55 Junior Poster in Training

1) Use the code tags.
2) It is something like this.

System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(ScreenShotConnectionString);

// Create the InsertCommand.
System.Data.SqlClient.SqlCommand cmd = new SqlCommand("INSERT INTO Table_1 (ScreenShotNumber, TestScriptID, StepNumber, TesterInitials, Date, DocumentNumber) "
 +"VALUES ( " + ScreenShotNumber + " , " +  TestScriptID +" , "  + TesterInitials + " , " TesterInitials + " ,  " +  DocumentNumber ") ", sqlConnection1);
try
{

//open the connection to the database
sqlConnection1.Open();

}

catch (ConfigurationErrorsException ex)
{
MessageBox.Show("Error in connection ..." + ex.Message);

}
finally
{
sqlConnection1.Close();
}
}

}
}

3) Parameters are used with stored procedures. There is no need to use here and more over you can't.

lighthead 55 Junior Poster in Training

Using

plz reply soon it is urgent...

does not help you get answers faster. Avoid it the next time.

You can import the data into SQL server database table easily. You can pivot the table using PIVOT in SQL query. Then subsequently read the data to datatable.
You can get the procedures to do so from previous threads of this forum or try googling. If you encounter any other problems doing so ask further.:)

kvprajapati commented: using Urgent; +9
lighthead 55 Junior Poster in Training

1) I have a doubt in your Battle method.

if (p1Card.FaceVal > p2Card.FaceVal)
            {
                rn = r.Next(1, 2);
                if (rn == 1)
                {
                    p1.AddCard(p1Card);
                    p1.AddCard(p2Card);
                }
                if (rn == 2)
                {
                    p2.AddCard(p2Card);
                    p2.AddCard(p1Card);
                }
                player1.GetWins++;
                player2.GetLosses++;
                return "Player 1 has won!";
            }

You are giving the cards to the winner not only based on the value of the card but also on the random number generated.
If you were trying to shuffle the won cards before putting them into the winners deck, you might have to do.

if (p1Card.FaceVal > p2Card.FaceVal)
            {
                rn = r.Next(1, 2);
                if (rn == 1)
                {
                    p1.AddCard(p1Card);
                    p1.AddCard(p2Card);
                }
                if (rn == 2)
                {
                    p1.AddCard(p2Card);
                    p1.AddCard(p1Card);
                }
                player1.GetWins++;
                player2.GetLosses++;
                return "Player 1 has won!";
            }

Or is there any other reason you are using the random number for?

2)The return value of Battle is not being used.
So, you might want to do

sStatus = Battle(player1, player2); // Battle

in playgame method.

3) In the Battle method if the facevalues of the cards are the same then the cards are not added to the deck. This successively decreased the total number of cards in the game.
You might want to add them to the respective decks.

lighthead 55 Junior Poster in Training

Check what method is being called for onload event. private void Form2_Load_1 makes me think, there might be a different method associated with the onload event.

lighthead 55 Junior Poster in Training

Who am I?
Manoj, just another random person to you.

What do I do?
Recently graduated and currently doing nothing.:P

What am I doing here?
Trying to keep my mind engaged ...:D

lighthead 55 Junior Poster in Training

I assumed it was MS SQLMS as you didnt mention the datagridview and posted the question in the MS SQL forum.
If you have solved your problem mark this thread as solved.:)

lighthead 55 Junior Poster in Training

Is that the screen shot of MSSQL management studios?
If it is then you cannot replace it with an image. If it is in your application then it is possible. To answer further we need to know more about the application.

lighthead 55 Junior Poster in Training

You can do it using stored procedure. In stored procedure A

exec ProcB param1 param2

where param1 and param2 are in parameters to Procedure B.

lighthead 55 Junior Poster in Training

It shouldn't normally happen. Check the value of the Label7 in Button2_Click when converting to int. Something must be changing the value of label7.

lighthead 55 Junior Poster in Training

Actually System.Numeric contains a member, BigInteger a Value type. I tried IL DASM and found it different from the object browser. Unfortunately it is not accessible now. It contains really cool stuff and you cannot access it:P.See here for details if you have not already seen.

ddanbe commented: Thanks for this information! +7
lighthead 55 Junior Poster in Training

You put the message box in the wrong place.

if (tb != null)
                    {  
                        if(!string.IsNullOrEmpty(tb.Text))
                        {
                            Form2 form2 = new Form2();
                            form2.Show();
                        }
                        else
                       {
                          //error message goes here...
                       }
                    }
wingers1290 commented: Ecellent +1
lighthead 55 Junior Poster in Training

Create a field in the database preferably bool. Set the value of the newly inserted rows as true. Use it to load the value of he checkbox.

lighthead 55 Junior Poster in Training

I don't understand your question. Please explain...

lighthead 55 Junior Poster in Training

I was curious as in my fair share of crashes , all the programs show some sort of messsagebox with the trace. The OP described it as 'the program has stopped working, windows is checking for a solution' , which is new to .NET crashes (at least for me).

@ddanbe
Its a welcome relief.:) This forum is sleeping now anyway.

lighthead 55 Junior Poster in Training

I was curious about why a .NET program crashes without showing a debugging message that you generally see.
Instead I find you too...carry on you two :)
Haha this is i more interesting.:P

lighthead 55 Junior Poster in Training

List in the sense , to get the links from the site?

lighthead 55 Junior Poster in Training

printf returns the number of bytes printed to the terminal. So the expression printf("HI")-2 returns 0. We end up with while(0){} .
For further clarification on printf visit here.
As printf is the expression used as the condition for the 'while' loop, no semicolon is required.It is same as

int val = printf("HI");
while(val - 2)//value of val is 2.
{

}
lighthead 55 Junior Poster in Training

Read this.
And try googling..:)

lighthead 55 Junior Poster in Training

1) Use the code tags as mentioned.
2)

TC = getchar();

Has been used 2 times in a loop, the second value is being over written and is lost.
3) And the construct (TC = getchar() != '\n') actually is read by the compiler as (TC = (getchar() != '\n')) .
Hence it gives TC a value of 1 meaning true until '\n', where it gives 0.
So, use either one of the constructs.

while ( (TC = getchar()) != '\n')
{
//...
}

or

TC = getchar();
while ( TC != '\n')
{
//...
TC = getchar();
}

4)When you are printing the results you are passing only two parameters when 3 are required. The third is the percentage calculation. Make sure to cast the value to float before you calculate the percentage. (float)AA[TC]/TL)

lighthead 55 Junior Poster in Training

A few things about your post
1) Use Code tags like this , if you didn't already know.
2) .NET is not a language, the language you are using is VB.
3) If you already know to program on .NET with VB its not too difficult to learn to do it in C#. Here is a starter.

lighthead 55 Junior Poster in Training

1) I believe NATURAL JOIN is not supported in MSSQL.
2) You cannot select FamName, GiveName, DeptNum without group by including them.

You must be using a different database server, surely not MSSQL.
Regarding your question about combining the two, the columns in the tables are needed to further answer your question.

lighthead 55 Junior Poster in Training

Adding to that.
1) The reference types can have more than one reference to the themselves. It would be ambiguous getting variable names even if you were able to access such information.
2) The debugger can know names of variables and other information from the metadata. But only when compiled for debugging and you cannot access them programmatically.
3) You can do this though.

Ramy Mahrous commented: Very nice link. +8
lighthead 55 Junior Poster in Training
Array[4] =  Array[4].Replace(Array[4].ToString(), lnewvalue.ToString());

A few other things.
1) () invokes the method.
2) You assign the return value of .Replace() method to the string.
3) Its better not to use Array as a variable name, as there exists a class already in .NET which can cause confusion.

>>didnt see your reply while posting ddanbe:)

lighthead 55 Junior Poster in Training

This might be helpful.

lighthead 55 Junior Poster in Training

Mark it as solved.

lighthead 55 Junior Poster in Training

Thread is a built in class in .NET to allow threading.
firstThread is a new thread you are creating.

new Thread (new ThreadStart (Method1))

Creates a new instance of the thread.The code that is to be executed is method 'Method1'. The new thread cannot directly run this method so we have to create a delegate.

new ThreadStart (Method1)

ThreadStart is that delegate, we create a new instance of it and supply it to the thread.
After this you have to call Start to run the thread.

firstThread.Start();

You might want to check out this.

lighthead 55 Junior Poster in Training

Your function is correctly returning a list of at most 'num' lines in the file. There were no blank lines. You might want to recheck other parts of the program.

lighthead 55 Junior Poster in Training

Nice piece Ramy , my post was stupid anyway.

lighthead 55 Junior Poster in Training

A better method is to use a RegularExpressionValidator. As post #3 suggests mark this post as solved.

lighthead 55 Junior Poster in Training

You can copy the text from the RichTextBox into a String and search it using IndexOf method.

lighthead 55 Junior Poster in Training

Adding to that, if you want ease of development choose C#. This I say because of VS. There is nothing like Visual Studios.

lighthead 55 Junior Poster in Training

Ya, its is working . Use a break in else part see the values of the data returned. And did you correct the problem mentioned in my earlier post.

lighthead 55 Junior Poster in Training

Your code is working fine. When you login the second form is being shown.
Make the uid unique in the database. As you have have two entries in your database for same uid it might be producing problems.

lighthead 55 Junior Poster in Training

Are you getting error or are you getting a different result. Post some details so that we can help.

lighthead 55 Junior Poster in Training

1) I thought that 'bryangarcia' did not get the line

read value of the integer variable first_int from the user's input?

so, i helped him. It would have be a pity if the thread had dragged on just because the obvious possibility was not explored.
2)

Its just the culture here to make people try and learn rather than given them the code well arranged in a golden platter.

I am curious as to know as to how you would have made him learn to read an user's input into a variable.
3) My reply to the post does not question anyone's reputation. I hate it become such a bother to you, as it had nothing to do with you.
Next time I would make sure to check with you before giving any code on this forum:).

lighthead 55 Junior Poster in Training

I think it means, read an integer as input from the user and assign it to the integer variable first_int.

int first_int;
scanf("%d",&first_int);

If you are still getting error, we need code and more detail to answer.

csurfer commented: Make people try and learn rather than giving them the codes directly from next time. :) -1
jephthah commented: does not deserve Neg Rep. +13
lighthead 55 Junior Poster in Training

I suppose this is your problem.

if ((reader(0) = textBox7.Text) && (reader(1) = textBox8.Text))
                   {
                       Form2 fr2 = new Form2();
                       fr2.Show();
                   }

Which should have been.

if ((reader[0].ToString().Equals(textBox7.Text) && (reader[1].ToString().Equals(textBox8.Text)))
                   {
                       Form2 fr2 = new Form2();
                       fr2.Show();
                   }

And you might want to use

if(reader.Read())
{
//code to read here.
}
lighthead 55 Junior Poster in Training

Is it a ASP.NET application or windows forms. Form post 4 it seems like a windows forms.
If its an ASP.NET thing then post 3 answers your question.If you need more detailed help provide more code or project as 'adatapost' sugested.

lighthead 55 Junior Poster in Training
private void button1_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Selected)//check if row is selected
                {
                    using (SqlConnection conn = new SqlConnection(ConnectionString))
                    {
                        SqlCommand com = new SqlCommand("delete_row", conn);//remove row from database
                        com.CommandType = CommandType.StoredProcedure;
                        com.Parameters.Add(new SqlParameter("@id", Convert.ToInt32(row.Cells[0].Value)));//unique id field of the datarow
                        conn.Open();
                        com.ExecuteNonQuery();
                        conn.Close();
                        dt.Rows.RemoveAt(row.Index);//remove row from the datatable that is bound to the gridview.
                    }
                }
            }

Hope this answers your question.

lighthead 55 Junior Poster in Training

No, you cant do that. The code is different for the forms.
You can try this
1) Detect the click event on the datagrid

dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);

2)Handle check for the right control do do the action required

void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 2)//check the column of the checkbox
                return;
            // your action go here
           //get the id for row, delete from database, delete from the  datatable that is source of your database            
        }

I dont know if there is a better way.

lighthead 55 Junior Poster in Training

Well, is there a question. Where is that you are facing difficulty and what help do you want.

lighthead 55 Junior Poster in Training

The solution provided in the previous thread of yours was a better one, i have modified it to make the colours permanent.
Hope this solves your problem.

lighthead 55 Junior Poster in Training

Can you tell me where you have added the lines.

lighthead 55 Junior Poster in Training

1) Create a new setting in Settings.Settings file in properties and set its type as System.Drawing.Color.
2) Where ever in your code you choose a colour from the user, set the property and save it.

Properties.Settings.Default.colour = c1.Color; //set the selected colour //to the setting colour which you had created.
Properties.Settings.Default.Save();

3) When Use this setting to set the colour where you require.

lighthead 55 Junior Poster in Training

Any for the gmail not throwing an exception. As it didnt when i tried it.

lighthead 55 Junior Poster in Training

The simplest way i think would be

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if(textBox1.Text!="")
                Convert.ToDouble(textBox1.Text);
            }
            catch
            {
                textBox1.Text = "";
            }

        }