Click here to Skip to main content
15,911,646 members
Home / Discussions / C#
   

C#

 
QuestionGet Group in LDAP Pin
AnhTin12-Apr-06 23:43
AnhTin12-Apr-06 23:43 
QuestionPost back where to inset the code Pin
papa198012-Apr-06 22:41
papa198012-Apr-06 22:41 
AnswerRe: Post back where to inset the code Pin
Dinuj Nath13-Apr-06 0:37
Dinuj Nath13-Apr-06 0:37 
GeneralRe: Post back where to inset the code Pin
papa198013-Apr-06 3:48
papa198013-Apr-06 3:48 
GeneralRe: Post back where to inset the code Pin
Dinuj Nath13-Apr-06 5:37
Dinuj Nath13-Apr-06 5:37 
QuestionAdding a row in a database Pin
alee15.10.8812-Apr-06 21:47
alee15.10.8812-Apr-06 21:47 
AnswerRe: Adding a row in a database Pin
J4amieC12-Apr-06 21:49
J4amieC12-Apr-06 21:49 
GeneralRe: Adding a row in a database Pin
alee15.10.8812-Apr-06 22:01
alee15.10.8812-Apr-06 22:01 
I have a database with some questions and each question has a unique ID.

In my c# program I have a form with a datagrid showing all these questions and 2 textboxes, 1 showing the id of the question (txtQstID) and the other showing the question (txtQst).

Then I have a button (btnAdd) that when I clicks it a new question is added in the datagrid. The new question is entered by the user in the txtQst textbox. But the ID of the question textbox is readonly so the user cannot enter anything in it.

So I did the following in the add button: -
//getting the maximum ID from the Qst_ID column
System.Data.OleDb.OleDbCommand oCommandMax = new System.Data.OleDb.OleDbCommand("SELECT MAX(Qst_ID) FROM Questions", conn);
object objMax = oCommandMax.ExecuteScalar();
string maxValue = objMax.ToString();

//parsing the maxValue to integer
int newRecord = (int.Parse(maxValue));
//adding 1 to the maximum number
newRecord++;

//displaying the new ID in the txtQstID textbox
this.txtQstID.Text = (newRecord.ToString());

//CreateNewQuestion is a method found in Class 1
Class1.CreateNewQuestion(txtQstID.Text, txtQst.Text);

//The following is the code found in Class1: -

public static void CreateNewQuestion(string ID, string Question)
{
DataRow drNew = DS.Tables["Questions"].NewRow();
drNew["Question_ID"] = ID;
drNew["Question"] = Question;

DS.Tables["Questions"].Rows.Add(drNew);
}
GeneralRe: Adding a row in a database Pin
J4amieC12-Apr-06 22:36
J4amieC12-Apr-06 22:36 
GeneralRe: Adding a row in a database Pin
albCode12-Apr-06 23:47
albCode12-Apr-06 23:47 
GeneralRe: Adding a row in a database Pin
J4amieC13-Apr-06 0:14
J4amieC13-Apr-06 0:14 
AnswerRe: Adding a row in a database Pin
Guffa13-Apr-06 1:31
Guffa13-Apr-06 1:31 
GeneralRe: Adding a row in a database Pin
J4amieC13-Apr-06 1:45
J4amieC13-Apr-06 1:45 
AnswerRe: Adding a row in a database Pin
Guffa12-Apr-06 21:51
Guffa12-Apr-06 21:51 
QuestionThread Synchronization program Pin
eric_tran12-Apr-06 21:31
eric_tran12-Apr-06 21:31 
AnswerRe: Thread Synchronization program Pin
J4amieC12-Apr-06 21:47
J4amieC12-Apr-06 21:47 
GeneralRe: Thread Synchronization program Pin
eric_tran12-Apr-06 21:53
eric_tran12-Apr-06 21:53 
QuestionRandom number Pin
eric_tran12-Apr-06 21:13
eric_tran12-Apr-06 21:13 
AnswerRe: Random number Pin
V.12-Apr-06 21:16
professionalV.12-Apr-06 21:16 
QuestionCombobox value change Pin
Kagisho12-Apr-06 20:58
Kagisho12-Apr-06 20:58 
QuestionHelp me Pin
AnhTin12-Apr-06 20:38
AnhTin12-Apr-06 20:38 
GeneralRe: Help me Pin
Guffa12-Apr-06 20:57
Guffa12-Apr-06 20:57 
AnswerRe: Help me Pin
Colin Angus Mackay12-Apr-06 22:10
Colin Angus Mackay12-Apr-06 22:10 
QuestionTimer Pin
rahultaing12-Apr-06 20:36
rahultaing12-Apr-06 20:36 
AnswerRe: Timer Pin
Colin Angus Mackay12-Apr-06 20:38
Colin Angus Mackay12-Apr-06 20:38 

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.