Results 1 to 6 of 6

Thread: listbox to database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Posts
    29

    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
    Arvinder Gill

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    How about storing listbox content in a flat file !!
    otherwise , show the code that's not working for you .

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Posts
    29

    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
    Arvinder Gill

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Flat file is like a text file .... .
    Are you getting any error in the above snippet code ?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Posts
    29

    Question 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?..
    Arvinder Gill

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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
  •  



Click Here to Expand Forum to Full Width