|
-
Mar 6th, 2004, 02:51 AM
#1
Thread Starter
Junior Member
listbox to database
hi...
i have a checklistbox, when the user clicks an item in the checklist it is added into a listbox...
i want it to store the items in the listbox into the database...
i tried using listBox.tex., but it seems that nothin is bein stored into the column in the database.
pls help
-
Mar 6th, 2004, 04:18 AM
#2
Sleep mode
How about storing listbox content in a flat file !!
otherwise , show the code that's not working for you .
-
Mar 6th, 2004, 05:15 AM
#3
Thread Starter
Junior Member
listbox to database
wooo...im lost....whats a flat file...and i guess i cant do that 'cos thats not gonna go down well with my client..
anyways
here's my code
Code:
private void btnSend_Click(object sender, System.EventArgs e)
{
//string med = (string) InsListBox.Items.ToString();
//MessageBox.Show(med.ToString());
try
{
oleDbConnection1.Open();
//if(QuantityListBox.Text != "" && InsListBox.Text != "")
//{
oleDbDataAdapter2.InsertCommand.CommandText = "INSERT INTO DiagPhar ([Acct ID], [Trans ID], Medication, Instructions, Quantity) VALUES ('"+txtAcctID.Text+"' , '"+txtTranID.Text+"' , '"+MedListBox.Text+"' , '"+InsListBox.Text+"' , '"+QuantityListBox.Text+"')";
oleDbDataAdapter2.InsertCommand.ExecuteNonQuery();
MessageBox.Show("Patient's prescription has been sent to the Pharmacy department" , "Information");
//}
//else
//{
// MessageBox.Show("All Text Boxes Should be Filled with Information","Reminder");
//}
}
catch (Exception SendError)
{
MessageBox.Show(SendError.ToString());
}
finally
{
oleDbConnection1.Close();
}
well is there a way where u can take whats in listbox1 and put it into a string.....that way i can store the string into the database..right?...can u show me how do i do that
-
Mar 6th, 2004, 05:21 AM
#4
Sleep mode
Flat file is like a text file .... .
Are you getting any error in the above snippet code ?
-
Mar 6th, 2004, 07:02 AM
#5
Thread Starter
Junior Member
no error at all..
thats the funny thing...there's no error at all....it processes well only thing is that the columns in the database that are s'pose to be filled with information from the listbox is empty....
the other way i can do this is have a textbox instead of a listbox...but how do i transfer from one textbox to another?..
-
Mar 6th, 2004, 07:13 AM
#6
Sleep mode
To make sure that code which follow the if structure is executed , make your selection in the listbox and checklistbox , then remove the if statement and try .
Last edited by Pirate; Mar 6th, 2004 at 07:22 AM.
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
|