I'm sorry that I'm not explaining well. But actually that's what I want... to search that particular row by using a row filter. any idea?
alee15 10 88
Posts
-
Getting a particular field from a database -
Getting a particular field from a databaseActually it's working... but it isn't logging on with any accounts i'm trying with. The underneath is the code I have in the button submit string occupation = (UHandler.UserLogIns.Rows[0]["Occupation"].ToString().ToUpper()); if(occupation == "STUDENT") { Session["userID"] = txtUsername.Text; Response.Redirect("UsersViewProfile.aspx"); } The problem is that I do not have a row filter which returns that 1 particular row, so it's searching in the first row where the occupation of that row is Teacher. Did you understand me now?
-
Getting a particular field from a databaseHi all, I am doing a website with asp.net and I would like to know how to get a particular field from a database. After that the user log ins, I need to know if the user is a student or a teacher by checking the occupation that is saved in the table Userlogins in the Database. I tried to do something like the following but unfortunately it did not work //ds is the typed Data Set //UserloginsDataTable is the table where the occupation is saved //Occupation is the name of the column if(ds.UserloginsDataTable[0].Occupation.ToString().ToUpper() == "STUDENT") { } Can anyone tell me if I am doing it right and if yes why isn't it working Thanks a lot guys
-
Getting a value from another formHi all, I have a textbox in Form1, where the user of the mentioned program is going to enter his name. Then I have another Form (Form2) in which I would like to display the name of the user by getting it from Form1. I am using MDI. Can I do it? If so, can you help me please! Thanks a lot for your help
-
Deleting from an SQL databaseOhh thanks... I arranged the quotes and it worked out Thanks a lot!!
-
Deleting from an SQL databaseHi all, I am doing a program with c# in which I am connecting it to an SQL database. I have a button (called btnDelete) in which in it I have the following code:- string query = ("DELETE FROM tblUsers WHERE User_name = ("+ txtDelete.Text +")"); SqlCommand myCommand = new SqlCommand(); myCommand.CommandText = query; myCommand.Connection = myConnection; myCommand.ExecuteNonQuery(); //Calling a method to update the database UpdateDataIntoDatabase(); MessageBox.Show( "Deleted." ); When I run the program and click the delete button the following error occurs pointing in the myCommand.ExecuteNonQuery() part:- An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll Additional information: System error. Can some one please tell me what do I have because I can't see anything wrong! Thanks a lot guys
-
Insert in a tableHi everyone, I have a small problem which I really need to solve today. I am doing a program which the user needs to log in. Now, when the user clicks the login btn, the username of that particular user is saved in a table called Marks. Then a new form is opened in which the user can do a small exam and finally submit it. When he clicks the submit btn the mark is saved in the table, in the column called subjectMarks, near the username which was already saved before (in the column userName). Unfortunately it is working wrong since the username is saved in the first row and then the mark is saved in the 2nd row. How can I do it? The following is the code I used in the submit btn: string query = ("INSERT INTO Marks (" + subjectMarks + ") VALUES ('" + marks + "')"); OleDbCommand myCommand = new OleDbCommand(query); myCommand.Connection = myConnection; try { myCommand.ExecuteNonQuery(); } catch(Exception ex) { ex.ToString(); } Thanks
-
Date in DataBindingI didn't understand you quite well. How can I do that?
-
Date in DataBindingHi everyone, I have a problem re: DataBindings. I binded a textbox with a database in which I would like to show the date in it, but unfortunately I can't remove the time, so that in the textbox the date only is shown. How can I do it? The following is the code I used for databinding. this.txtDOB.DataBindings.Add("Text", DBHandler.DS, "UserLogInsteacher.DateOfBirth"); Thanks a lot!!
-
Adding a row in a databaseI 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); }
-
Adding a row in a databaseHi, I would like to add a record in the last row of a database from a c# program. I have a database with the first column called ID which is unique. I tried doing this by finding the maximum number in that column and then adding 1 to it but it doesn' work. Thanks
-
Random in C#Thank you, Thank you I've done it :-D
-
Random in C#Actually at the moment I'm working with windows and when I'll be ready I'm going to do it in a web application.
-
Random in C#Yes a new question is random everytime I click the Next button. But it's not keeping track of the ten clicks that the user makes since I don't know how and at the moment the button is not disabled.
-
Random in C#Hi everyone, I've got a problem and I can't solve it with anything! I have a button that when one clicks on it a groupbox is enabled showing a label with the value of a row which was random from a database. Then when one clicks the next button another question is random and displayed in the same label.Now I would like that after the user clicks the next button for ten times, it is disabled. How can I do this? :confused: Thanks
-
Closing a form and enable another one!I don't think you understood me. I disabled the form but I would like that when I close the About form, the main form will be enabled again. How can I do that? thanks
-
Closing a form and enable another one!Hi, I am making a program and in the menu bar I did a menu bar item called About. Now I would like that when I open the About form the main form will be disabled. I did that and it worked. But now how should I make it enabled again after I close the About form? Thanks a lot
-
Close ButtonOhh I made it, Thanks a lot people for helping me! :-D
-
Close Button[Message Deleted]
-
Close ButtonI would like to know how to display a message box with an "Are you sure you want to exit?" when someone clicks the close button, therefore the cross button. I managed to do it in a simple button but I think it's different in the close button! Can someone help me please?! Thanks ;) Alison