Hi everybody

:sad: need help plz

how can i list items from a database into a CheckedListBox , using VB.Net and MS Access db ??

hi ....
i did this ..first u need dataset and data adapter...
then u will go through each row in dataset and collect the items in one string...then use
CheckedListBox1.Items.Add(the string u collect)

ok i hope this will help

hi ....
i did this ..first u need dataset and data adapter...
then u will go through each row in dataset and collect the items in one string...then use
CheckedListBox1.Items.Add(the string u collect)

ok i hope this will help

thanx

i'll try to do it
if i face any problem, can i ask you again??:-|

thank you very much :)


i'm sorry .... i have too many questions :rolleyes:


Dim items As String
items = Me.DsStaffName. ............... << what should i write here?? :rolleyes:
CheckedListBox1.Items.Add(items)


see.... when u have dataset it represent the table in database that u have
so if u have r rows and c column ...u will go through one row at time and collect all the columns in it..
item=""
with 2 whiles one for rows and inner one for columns collect each cell and add it to item like this.....
item=item & dataset.TabelName.Rows(r).item(c)
CheckedListBox1.Items.Add(item)

hope it is helpful

hi

sorry (manal) ,, iam a beginner in VB.Net
so, i want to learn more from you


i wrote this code but it doesnot work
what is the wrong ?

notice: i want to retrive one colomn from the table

Dim items1 As String
Dim r As Integer = 0
Dim c As Integer
While r < DsStaffName.StaffAccount.Rows.Count
items1 = items1 & DsStaffName.StaffAccount.Rows(r).Item(c)
r = r + 1
CheckedListBox2.Items.Add(items1)

End While


;) thanx for your help

hi again..just one column ..so no need to collect it to one string i thought u want to show row of many columns..
any way..ofcourse u need to give c value at start...
Dim c As Integer=number_of_column_u_want
While r < DsStaffName.StaffAccount.Rows.Count
items1 = DsStaffName.StaffAccount.Rows(r).Item(c)

CheckedListBox2.Items.Add(items1)
r = r + 1

end while..
i think this must work i hope...

it didnot work :sad:


Dim items1 As String
Dim r As Integer = 0
Dim c As Integer = 1
While r < DsStaffName1.StaffAccount.Rows.Count
items1 = DsStaffName1.StaffAccount.Rows(r).Item(c)
CheckedListBox2.Items.Add(items1)
r = r + 1
End While

i think the error in this statement (DsStaffName1.StaffAccount.Rows.Count) ... but i do not know where or why!!!
bcz i add a label to show me the count .. but it always (0)
:?:

it didnot work :sad:


Dim items1 As String
Dim r As Integer = 0
Dim c As Integer = 1
While r < DsStaffName1.StaffAccount.Rows.Count
items1 = DsStaffName1.StaffAccount.Rows(r).Item(c)
CheckedListBox2.Items.Add(items1)
r = r + 1
End While

i think the error in this statement (DsStaffName1.StaffAccount.Rows.Count) ... but i do not know where or why!!!
bcz i add a label to show me the count .. but it always (0)
:?:

it works with me....just check if the column 1 exist in ur tabel....
and did u clear dataset and fill dataadapter???

good evening

thank you very much:cheesy:

it works since 2 days, but i could not connect with internet ;)


i have another question.. can i ask?? ;) :o

good evening

i want to write records from the database to a word document

i wrote this code

Me.applicationWord.Visible = True
Me.applicationWord.Activate()
applicationWord.Documents.Add()
Dim parra As Word.Paragraph
Dim r As Integer = 0
Dim details As String
While r < Me.DsStaff1.StaffAccount.Rows.Count
details = Me.DsStaff1.StaffAccount.Rows(r).Item("S_Name")
parra = documentWord.Paragraphs.Add()
parra.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
applicationWord.Selection.Font.Color = Word.WdColor.wdColorBlack
applicationWord.Selection.Font.Size = 18
applicationWord.Selection.Font.Name = "Arial"
applicationWord.Selection.TypeParagraph()
documentWord.Application.Selection.TypeText(details)
r = r + 1
End While


but when the word document opened i have only a (38 "No. of DB record) empty lines
:rolleyes: what is the wrong with it??!!!

This question has already been answered. Start a new discussion instead.