Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox and Access 1

Status
Not open for further replies.

ridifvx

Programmer
Apr 10, 2003
34
ID
HI guys...

as usual newbie question :)

ListBox can binding dataset right?:). well a big confuse then. i have an Access database (say it i have a.mdb and it has 1 table xy table, 2 field x and y). i can connect it with my app using OleDBconnection and manipulating using oleDBcommand. But

1.I want to access x field (in xy table). ANd every data in x field is become a list of item in a listBox1, well how can i do that?

2.It's possible? the changes in a listbox1 reflected in my database too . I mean if I delete an item using removeat so in database that selected row is deleted too, how can i do that?


please i really need a help for this kind problem, it's really bored to read all of my MSDN cd :(, i have no more space in my drive to install MSDN (sorry a poor one to but HD) and no C# book in my city

Thanks, sorry 4 my English

BTW thanks to --ObisLavu--- for answering my last question 2 weeks ago
 
1)


foreach(DataRow dataRow in dataTable.Rows)
{
comboBox1.Items.Add(dataRow["x"]);
}

Not sure about #2.....

hth,

Smitty
 
I had already done for question number one this morning but thanks Smitty you helpped me alot

Help number two question please?somebody
 
Within the event that removes the item, you could manually remove it from the DB. That's what I've done in my programs.

Set up the DataAdapter's DeleteCommand property to

"DELETE * FROM _Table_ WHERE _FieldName_ = _UID_;"

UID is the primary key's value for the row that you want to delete... How you get that from the information in the listbox depends on how you've set things up.

Then, open the dataconnection object, run

Adapter.DeleteCommand.ExecuteNonQuery();

and Close the dataconnection.

Ben

There's no place like 127.0.0.1.
 
A star for you yeah good you make up my mind
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top