...

Listbox + retreiving

Mitsuki
04-26-2006, 08:55 AM
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 ...

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:

handshakeit
04-26-2006, 10:54 AM
is there any error in ur code ????
what it does so far?

Mitsuki
04-26-2006, 11:59 AM
the items appear in the listbox but i cant move it to the other listbox nor retreive the item information



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum