|
-
Feb 19th, 2004, 10:08 AM
#1
Thread Starter
Junior Member
Displaying it in Text Boxes?...how?
Hi,
Code:
private void btnGEtDetails_Click(system event....)
{
if (txtAcctID.Text != "")
{
myConnection1.Open();
sqlDataAdapter1.SelectCommand.CommandText = "("SELECT (Name, ICNO) FROM Patient WHERE ACCTID ='"+txtAcctID.Text+"'")";
sqlDataAdapter1.SelectCommand.ExecuteNonQuery();
//fill in the txtName and txtICNO with info from the Database
myConnection1.Close();
}
else
{
MessageBox.Show("Please fill in the Account ID text box","Reminder");
}
what id like the function to do is to get the NAME and Identity Card NO(ICNO) according to the ACCT ID and put the information into their respective textboxes...(txtName and txtICNO)
i havent compile this code yet....if there's a mistake pls show me where and the solution? (hope im not askin for much...just a beginner)
thx a million
-
Feb 19th, 2004, 01:01 PM
#2
Sleep mode
Is this something like what you want !
PHP Code:
int ACCT_ID=0;
string NAME="";
int ICNO=0;
switch (ACCT_ID)
{
case 10:
//DO something here
break;
case 20:
//Do something else
break;
default :
//Default fires
break;
}
-
Feb 20th, 2004, 04:10 AM
#3
Thread Starter
Junior Member
this is the actual code...the get details button is working, the account id entered does exist in the Database but the display method gives me the message box saying the record does not exist..why why?....
Code:
private void btnGetDetails_Click(object sender, System.EventArgs e)
{
try
{
if(txtAcctID.Text != "")
{
dsPatient2.Clear(); //clears the dataset from the last operation (for multiple deletion)
oleDbConnection1.Open();
//creates the SQL qeury to find the Patient Record with the specified Account ID.
oleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM Patient WHERE [Acct ID] = '"+txtAcctID.Text+"'";
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
//fill Dataset(dsPatient2) with the rows resulting from the Query.
oleDbDataAdapter1.Fill(dsPatient2, "Patient");
//Runs the constructor Display();
Display(dsPatient2);
}
else
{
MessageBox.Show("Enter Account ID and then press GET DETAILS","Information");
}
}
catch(Exception Error4)
{
MessageBox.Show(Error4.ToString());
}
}
private void Display(System.Data.DataSet dsPatient2)
{
try
{
System.Data.DataTable Patient2 = dsPatient2.Tables[0];
if(Patient2.Rows.Count != 0)
{
int recordNumber = (int) Patient2.Rows[0][0];
txtNameDel.Text = (string) Patient2.Rows[0][1];
txtICNODel.Text = (string) Patient2.Rows[0][6];
}
else
{
MessageBox.Show("The Account ID/Patient Record does not exist","Information");
}
}
catch(Exception Error5)
{
MessageBox.Show(Error5.ToString());
}
}
private void btnDel_Click(object sender, System.EventArgs e)
{
try
{
if(txtNameDel.Text != "")
{
//DialogResult = MessageBox.Show("Are you sure you want to DELETE this record?","Warning");
oleDbDataAdapter1.DeleteCommand.CommandText = "DELETE FROM Patient WHERE [Acct ID] = '"+txtAcctID.Text+"'";
oleDbDataAdapter1.DeleteCommand.ExecuteNonQuery();
}
else
{
MessageBox.Show("Please Enter an Account ID first and press GET DETAILS","Information");
}
}
catch(Exception Error6)
{
MessageBox.Show(Error6.ToString());
}
oleDbConnection1.Close();
oleDbConnection1.Dispose();
}
-
Feb 20th, 2004, 12:05 PM
#4
Sleep mode
Can't say for sure why !! but it looks like the datatable doesn't get filled . Provide names of the tables instead of setting it by numbers . It may give you a clue where the error is .
Last edited by Pirate; Feb 20th, 2004 at 12:23 PM.
-
Feb 21st, 2004, 04:05 AM
#5
Thread Starter
Junior Member
Solved!
well..i somehow go it to work...anyways thx for the ideas and help!...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|