|
Yes it will.
I assume you have something along the lines of:
do
{
Console.WriteLine(...
...
s = Console.ReadLine();
} while (s != "9")
If so, then it will loop round for any sequence of keypresses follewed by an ENTER other than the '9' key followed by ENTER.
Remember that ReadLine will retrun with what has been pressed up to an ENTER - so if you only press enter, you will get and empty string. You will have to check for this and act accordingly.
Sorry if this sound vague, but your code fragment doesn't give us a lot to go on!
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
hi,
for reading a key you can use ReadKey method and a good practice for you're application is to use a switch statement like this:
Console.WriteLine("1:Add\n2:Sub\n3:Mult:\n4:Div");
Console.WriteLine();
Console.WriteLine("Press 9 to Exit or Enter to Continue ");
ConsoleKeyInfo cki = Console.ReadKey();
switch (cki)
{
case ConsoleKey.D9:
Console.WriteLine("exit");
break;
case ConsoleKey.Enter:
Console.WriteLine("continue");
break;
case ConsoleKey.D1:
Console.WriteLine("Add");
break;
case ConsoleKey.D2:
Console.WriteLine("Sub");
break;
case ConsoleKey.D3:
Console.WriteLine("Mult");
break;
case ConsoleKey.D4:
Console.WriteLine("Div");
break;
default: break;
}
Anyway I don't understand why use the ENTER key to continue? have you more option than 1,2,3 and 4 ?
Cheer's,
Alex Manolescu
|
|
|
|
|
Ok, so I have a DataGridView control with 7 columns, the column names are identical to the ones in my MySql Database and I have this code:
public partial class Form3 : Form
{
private MySqlConnection connection = new MySqlConnection();
private MySqlDataAdapter data = new MySqlDataAdapter();
public Form3()
{
InitializeComponent();
connection.ConnectionString =
"server=uhhhhh;"
+ "database=uhhhh;"
+ "uid=uhhhh;"
+ "password=uhhh;";
connection.Open();
MySqlCommand command = connection.CreateCommand();
command.CommandText = "select * from data";
data.SelectCommand = command;
DataSet dataset = new DataSet();
data.Fill(dataset, "data");
gridInfo.DataSource = dataset;
gridInfo.DataMember = "data";
gridInfo.Dock = DockStyle.Fill;
}
}
Basically what I want to do is retreive all the info from the DataBase, and show it in the DataGridView. I hope you can help me.
Regards,
Melvin
|
|
|
|
|
So did the DataGridView show anything?
|
|
|
|
|
Try removing the columns you have created for the DataGridView, then let the grid view build them itself by using the gridInfo.DataBind() method.
|
|
|
|
|
DataGridView does not have a DataBind method - GridView does (I've made that mistake myself!)
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
1. DataGridView and GridView are two different things.
2. OP wasn't clear enough about the what exactly he wants to show in the gridview. So, which columns are you asking to remove?
"No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem
|
|
|
|
|
What do you mean by all the information from the database?
"No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem
|
|
|
|
|
Ok, well its a DataGridView, and I just want every entry in the database, put in there. So the database has 7 columns, and for example it has an entry like this:
300,mark,male,homosexual,single,male,19
And I want the DataGridView to display that info, in the appropriate columns.
|
|
|
|
|
I generally use a datatable instead of a dataset, I find it easier to debug. I can't see anything to stop this code working, change the datasource to a table, debug and make sure you are getting data returned from the database.
I also never use the data member property with a table. This may be forcing the DGV to look for a TABLE in the dataset named data which does not exists of course!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
dataset DS = new Dataset
datatable DT = new DataTable
mysqlconnection connection = new mysqlconnection();
connection.ConnectionString = "blah blah blah"
connection.Open();
sqlite_comm = connection.CreateCommand();
string CommandText = "select * from data";
mysql_da = new MySQLDataAdapter(CommandText, connection);
DS.Reset();
mysql_da.Fill(DS);
DT = DS.Tables[0];
dataGrid1.DataSource = DT;
connection.Close();
|
|
|
|
|
I have a C# form users use to enter hours worked, sick time , vacation.
It is connected to access 2003 database.
The form does not have a login- each person just selects last name from combo box and any secure data is not visible on form.
is there a way I can display a current number of vacation hours, sick time left each week on form for each person.
I recieved an excel sheet with total number of vacation hours and sick hours each user has for this year at present. When someone uses time it has to calculated and updated.
I am uncertain of how of even how to start on this task. any ideas. I also have to have vacation time and sick time only available to user. no one else can view.
thank you,
|
|
|
|
|
You would force a user to select their name first and then query the data on the SelectedItemChanged event, same as you would select data from another data source on a different event, such as saving data on a button click
|
|
|
|
|
|
|
Go back to the article, and send the author a message there - use new message at the end of the article. That way they get an email to say you need help, rather than relying on them dropping in here and spotting your request.
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Hi folks,
I am entering data into the db from a winform. The save button handles the insertion of the form data into the db. The form has
all fields for insertion into the table. Some field of the table are set to database defaults like getdate() and suser_sname .
When I hit the save button .... the default values are not getting interted into the db they are NULL when i query the db.
please provide you suggestions to relove this issue . thanks
|
|
|
|
|
I think we will need to see the code for the save button - please use the "code block" widget when you post it.
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
{
tbSystem tb = new tbSystem();
tb.System_DeliveryDate = System_DeliveryDateDateTimePicker.Value;
tb.System_Description = System_DescriptionRichTextBox.Text;
tb.System_Name = System_NameTextBox.Text;
tb.System_Priority = (int)System_PriorityComboBox.SelectedValue;
tb.System_Status = (int)System_StatusComboBox.SelectedValue;
try
{
tmx.tbSystem.InsertOnSubmit(tb);
tmx.SubmitChanges();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
MessageBox.Show("Date is Validated and saved");
}
|
|
|
|
|
Check ur query otherwise it is not possible to face this type of problem.
(And past code also, For more exact answer)
Syed Shahid Hussain
|
|
|
|
|
Just pasted code in the reply above
|
|
|
|
|
i dont know if there is a way but when i face like this problem i did for loop to check if there is a null value and replace it with 0.
i hope that will help
|
|
|
|
|
Hi All,
I want to add description to already installed service.
Help Please
Regards,
Sunil G.
|
|
|
|
|
On the registry, change the "Description" key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\yourservice
|
|
|
|
|
Just a simple question
Is System.Array a collection ?
If it is, then why doesnt it come in the System.Collections namespace ??
The name is Sandeep
|
|
|
|