Reply
listbox / retreiving
Old 04-26-2006, 03:58 AM listbox / retreiving
Heba's Avatar
Average Talker

Posts: 28
hello
I have 2 listbox one of the listboxs retreives its items from an Access DB
and when it is moves to the other listbox it gets saves in another tbl ..
Also when the user presses on the item he should retreive all the info about it but cannot change anything ...

I am trying to do it
this is what i did so far ...
Code:
 OleDbConnection conn;
     OleDbCommand cmd;
     OleDbDataAdapter da;
    
    
        System.Data.IDataReader BFTbl() {
            string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\\Inetpub\\HASE" +
                "M\\HASEM.mdb";
            System.Data.IDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString);
    
            string queryString = "SELECT [tblNewItems].[strName], [tblNewItems].[Date], [tblNewItems].[AWB] FROM [t" +
                "blNewItems]";
            System.Data.IDbCommand dbCommand = new System.Data.OleDb.OleDbCommand();
            dbCommand.CommandText = queryString;
            dbCommand.Connection = dbConnection;
    
            dbConnection.Open();
            System.Data.IDataReader dataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
    
            return dataReader;
        }
     private void Button1_Click(object sender, System.EventArgs e)
     {
     string strSelection;
     if (ListBox1.SelectedItem != null)
     {
     strSelection = ListBox1.SelectedItem.Text;
     if (ListBox2.Items.FindByText(strSelection)== null )
     {
     ListBox2.Items.Add(strSelection);
     ListBox2.SelectedIndex =0;
     ListBox1.Items.Remove(strSelection);
     }
     }
     }
    
     private void Button2_Click(object sender, System.EventArgs e)
     {
     string strSelection;
    if (ListBox2.SelectedItem != null)
         {
         strSelection = ListBox2.SelectedItem.Text;
         if (ListBox1.Items.FindByText(strSelection)== null )
         {
         ListBox1.Items.Add(strSelection);
         ListBox1.SelectedIndex =0;
         ListBox2.Items.Remove(strSelection);
         }
         }
         }
    
         private void Page_Load(object sender, System.EventArgs e)
         {
         if (!IsPostBack)
         {
        //Put user code to initialize the page here
         conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\HASEM\\HASEM.mdb;");
         cmd = new OleDbCommand("select strName from tblNewItems",conn);
         da= new OleDbDataAdapter(cmd);
    
         Dim dsColor = new DataSet();
         da.Fill(dsColor);
    
         ListBox1.DataSource = dsColor;
         ListBox1.DataTextField = "strName";
         ListBox1.DataBind();
         ListBox1.SelectedIndex = 0;
         }
         }
</script>
Please I need your help I have like 10 more pages to validate in 2 weeks and it is a very short time :cry2:
Heba is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-28-2006, 08:16 AM Re: listbox / retreiving
THByte's Avatar
Junior Talker

Posts: 3
Location: Romania
What is not working, or you need some ideas?
__________________
Nothing is impossible if you believe so.
THByte is offline
Reply With Quote
View Public Profile
 
Old 04-29-2006, 01:31 AM Re: listbox / retreiving
Heba's Avatar
Average Talker

Posts: 28
The items are retrieved from the database to the listbox but I cant move it to the other listbox ... I am kind of confused and I need guidence please
Heba is offline
Reply With Quote
View Public Profile
 
Old 05-01-2006, 08:35 AM Re: listbox / retreiving
Novice Talker

Posts: 12
You r moving daata on btn click event
is it not moving?
what is the error it showing??/
handshakeit is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to listbox / retreiving
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11541 seconds with 13 queries