Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Saving ListView Items To Database


Hi this is Amar,

I am new to vb.. I wanna save ListView items to database and I have to retrieve from data base again. Please tell me how to solve this .. for MSAccess as database...
If anybody having the code... please send it to me...

I am very thankful to you..


Regards,
Amarendra.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Saving Listview Items Into Access Database....[Urgent]
I have two textbox and one listview in the form(in report mode). List view contains five columns, say, SerialNumber, Products, ProductDescription, Unitprice and Amount. Listview contains many subitems. One textbox contains Customer's Name and Other Contains the Invoice number. How to save all the listview subitems in access database for corresponding customer name and invoice number. Invoice Number is the unique one in the database.??

Looking for the help,
Saracjl
Thankx.

Saving Listview Items.
Hi guyz!can you please give an idea of saving item in listview in a database? I have populate 3 items in listview and I want to save that items in database. 3 items corresponds to 3 fields in my database. thanks!

Saving Items In ListView
How on earth do I save the items listed in my listview control and then reload them into the listview when I open my program again. This is what I have, and it just doesn't do anything (it just causes an error):

Code:
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
For i = 0 To ListView1.ListItems.Count
SaveSetting "AppName", "Form1", "list", ListView1.ListItems.Item(i)
Next i
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 0 To ListView1.ListItems.Count
ListView1.ListItems.Item(i) = GetSetting("AppName", "Form1", "list", " ")
Next i
End Sub


PLEASE HELP

Inserting ListView Items Into The Database
Hi!

I have 3 short questions that i hope you guyz can help me with

I have a few text fields that enters names, occupations and telephone numbers into a ListView control when the user clicks add...

how do I loop the list to enter each line of data into the database...

and also... how do you remove a specific line in a listview...
i've tried this
SocialFamilyList.ListItems.Remove(Index)
but this doesn't work

what's am i doing wrong...

and how do select a whole row when you click on the details in the listview control

Thank You For Your Time

~JoHn~

Removing Items From Listview And The Database As Well..
have a listview that allows the user to remove the items.. items in listview is retrieved from the database.. wat i'm doin is, when i right-click on the item in the list view, a menu pops up and if the user clicks on remove, will remove the item from the list, and not the database..

so lets say, there are 10 items in the listview, retrieved from the database, user removes 3.. how can i update my database in the sense that there will be 7 records left.. any idea?

i juz use this to remove from the listview..


VB Code:
lvwData.ListItems.Remove (lvwitem.Index)



thanks in advance

Show Multiple Items In Listview Taken From Database
How would I show multiple items from an Access database in a listview?

Example: Let's say my database looks like this:

Sender Subject Date
me@isp.com Some Subject 1-13-00 7:59AM
you@otherisp.com Some other subject 7-30-01 8:00AM

I want to load both items into a listview. My current procedure only loads one item at a time. Here is the procedure:


Code:
Dim Recordset As ADODB.Recordset
Select Case Node.Text
Case "Trash"
If Recordset.EOF = True Then Exit Sub
lvwMail.ListItems.Clear
With lvwMail.ListItems.Add(, , Recordset!Sender)
.SubItems(1) = Recordset!Subject
.SubItems(2) = Recordset!Date
End With
End Select

Recovering Checked Items In A ListView From A Database
I have been working on a program that stores ListView items in a random access file. I have been trying to store the items in such a way, that when I populate the ListView from the file it restore those items that were checked in the checkbox. It hasn't worked well. It lists the items that were checked twice, for some reason, one checked and one not, and omits the others.
Any suggestions?

Save Items From Listview To Access Database
I m doing my project of invoice management.......i gotta problem...............
How could I save the listview items in access database(listview is in report mode).....?
Suppose i have column called "Amount".........how could I sum up all the items in column named "Amount"
I m using visual basic 6.

Sabin Kumar Chhetri

Edited by - saracjl on 3/17/2005 5:46:12 AM

Saving Items (selected Items) In List Box To A Text File
I need help in coding the following:

1. Saving (or exporting) the items displayed in List Box to a text file.

2. I have a long list of data to be displayed. When I use this List box all of my data does not fit into the width. I was wondering if there is similar other way where I can do horizontal as well as vertical scrolling. I tried text box and its of no help i guess.

Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.

ex.

LV 1 LV 2
1. A 1. B
2. C 2. D
3. E 3. F


Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?

ex.

LV 3

1. A
2. C
3. E
4. D
5. E
6. F

Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.

ex.
________________
LV 1 l LV 2 l
l l
1. A l 1. B l
2. C l 2. D l
3. E l 3. F l
_______l_________l

Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?

ex.
_______
LV 1 l
1. A l
2. C l
3. E l
4. D l
5. E l
6. F l
_______l

Saving Datalist Items
how do i save all the items in my datalist with just one click of a button?..

im using ado control..

Saving ListBox Items .. Again You Say?
I'm a newbie to the world of EVB, but so far things have been going well..

Anyway, I want to save the contents of a ListBox to a text file and then be able to read the contents back into a ListBox. I have looked and tested the code that is on the Visual Basic forums (i.e. pizzamans sample), I notice this doesnt work in EVB environment. Unless I'm doing something really wrong, the error I get is:

Compile Error:

Expected end of statement

I think its complaining about part of the For loop, but I'm probably wrong. Has anyone got any sample code to get this ListBox thing working?

Cheers

Saving Items From A Combobox
How can I save contents of combobox using CommonControl Dialog?

Help Saving Items From Textboxes To An XML File
Hello Again

Here I am, I have yet another question about XML. I have 5 textboxes and I want to save them into an XML file. 3 of them are attributes of the first tag, then the 2 others are in that tag. Here is an example of the XML File:


Code:
<account name="blohag" pass="blahbl" plevel="2">
<created>6/9/2006 3:08:21 PM</created>
<lastlogin>6/12/2006 3:07:45 PM</lastlogin>
<gametime>00:43:41.1093750</gametime>
<guid>2261326</guid>
<guid>2261941</guid>
<ip>192.168.1.1</ip>
</account>
I don't need created, gametime, or any guids. I'm trying to make txtName (which would be the name attribute in <account>, txtPass, txtPLevel, txtLastLogin, and txtIP save to either overwrite the file if it's the same account name or create a new one.

If you know of any sample code that can help me out here please let me know, thanks.

Saving List View Items
Hi guyz!can you please give an idea of saving item in listview in a database? I have populate 3 items in listview and I want to save that items in database. 3 items corresponds to 3 fields in my database. thanks!

Saving Listbox Items To A Textfile?
Hey guys I have list8 listbox and I was wondering, how could I save its items to a textfile called scanlist.txt

I can use this code to save a textbox to a textfile.

Dim FF As Integer
Dim lngIndex As Long


Open App.path & "AutoScanStatus.txt" For Output As #1
Close #1
Open App.path & "AutoScanStatus.txt" For Append As #1
Write #1, Text2.Text
Close #1

Would I put Write #1, List8?

Saving New Items To A Combo Box In Runtime
Hi, Could anyone help please?

My program has a 5 combo boxes. "cboPC", "cboLap", "cboGen", "cboCable" and "cboAdd" and a text box "txtItem". In "cboAdd" there are the choices of the other 4 combo boxes in it. What i would like is when the Add button is clicked, it adds "txtItem" to the combo box chosen from "cboAdd" and saves it so that when the form is reloaded it is still there.

I have been told i need to write it to a file, but dont know how to do this? Help appreciated!

Here is the code i have so far for adding it to the combo boxes:


Code:
Private Function AddItem()

If cboCat.Text = "PC" Then
cboPC.AddItem txtAddItem.Text

ElseIf cboCat.Text = "Laptop" Then
cboLap.AddItem txtAddItem.Text

ElseIf cboCat.Text = "Cable" Then
cboCab.AddItem txtAddItem.Text

ElseIf cboCat.Text = "Backup" Then
cboBack.AddItem txtAddItem.Text

ElseIf cboCat.Text = "ID" Then
cboCard.AddItem txtAddItem.Text

ElseIf cboCat.Text = "General" Then
cboGen.AddItem txtAddItem.Text

End If

End Function

Saving The All The Items In A Listbox(Resolved)
How Do you save all the items in a listbox?
Will SaveSetting/GetSetting work here somehow?

Saving Items In ListBox Permenantly
Hi,

How can I save items in a list box permenantly, for example, on the click of button, prime numbers generate in the list box. I want to save the list of prime numbers so that next time when my application starts, the items should be there.

I want to use the listbox in the similar way for my application.

Thanx

Saving ListBox Items To A File
I'm making a program that contains a listbox where you can enter a combination of 3 letters and 3 numbers into one line. Since that's not the point lets keep going. I've tried many ways to make it save the ListBox data to a file. Not only that but it also has to load the data when the program starts up. How do I do that? Just for info, the user can only enter a maximum of 50 combinations, but he could enter less if he wishes to!

Loading And Saving Items To And From A Listbox?
I am making a program for my High School senior project and it includes a Log In form. When a user logs in, their name is added to a listbox. Is there a way to save the contents of this listbox to a file of some sort when the user logs in, and also be loaded from this file to the listbox when the form is loaded again? If this is possible, could someone please help me?

Thanks

When Saving In A Text File, How Do You Save Several Items?
I want to have the text file save several things...

I am using the code:

Open ("c:abc.txt") For Output As #1
Print #1, (Chr$(KeyAscii) & " ")
Close #1

how can I have it save the keys that are hit, without just writing overtop whatever else is there?

hopefully it is simple code, but if it isn't then I wont care.

I likely learned it earlier, but have forgotten it... heh.

Adding (and Saving) Items To A List At Runtime
I am creating a program that will run in the systray and when the user clicks the icon a menu of files will appear.
When the user selects a file the file will open in it's respective app (like Word or Excel).

I want to be able to give the user the option to add files to the list so they will be available next time he starts the app.
I'm betting that this will require some type of data file for the app to read and write to, but I don't have any experience with this...Any suggestions?

Also, I would like to allow the user to customize the layout of the menu so that he can arrange frequently used files at the bottom and even add spaces between groups of file items ...Any suggestions here?

Thanks guys and girls!!!

Saving Listbox Items To A Text File....
Code:
Private Sub Command1_Click()

Dim filenum As Integer
Dim MyString As String

MyString = lstData.Text ' set Variable to Text of TextBox
filenum = FreeFile ' let VB find a FreeFile # for you.


Open App.Path & " extsIMS.Txt" For Append As #filenum ' Open as Append to add data to end of file
      
   Print #filenum, MyString ' write the data to file
  
Close #filenum ' close the file
End Sub


What I need it to do is, save any text that is in the listbox, to the text file...I'm at a stump,
because every time i use anything other than lstData.text, it won't work..

Any help is greatly appreciated..

"Edit: The way it is now, I have to click on the "text" then save, and it only saves just that line. What
I'm looking for, is for it to save any data in the listbox, by clicking the command button."




Edited by - dwd121 on 12/27/2003 8:25:09 PM

Saving Listbox Items To Text File
Hi all,
I am planning to have a listbox on a form which has two columns Column1 and Column2. Both these columns have some terms listed out which i want to be stored into a text file at the click of a button. The name of the text file can be specified by the user by means of a User Input message box.

However, i wish that the terms whould be saved in the format as given below:

Column1Term1<TAB KEY>Column2Term1
Column1Term2<TAB KEY>Column2Term2
Column1Term3<TAB KEY>Column2Term3
Column1Term4<TAB KEY>Column2Term4
-------------
--------
-- and so on

Can someone please help me do this.
Thanks,
Lonely

Saving Items In A Listbox And Opening Them - Easy Question(?)
in my midi player app i'm trying to make an playlist but i want the user to be able to save it. how do you save information on the listbox as a file and open it? help me please!!!!

Saving Selected Items From A Listbox To A Text File
Hi folks,

I can use the following code to save the entire contents of a listbox to a text file, but I can't work out how to just save the selected items (I have multiselect set to 2).

Any ideas?

Simon

Dim file As String
file = "temp.dat"

On Error Resume Next
Open file For Output As #1
For i = 0 To lstWorkstations.ListCount - 1
a$ = lstWorkstations.List(i)
Print #1, a$
Next
Close #1

Saving Items(Please Reply ASAP) - Challenging Question - New Posts Need
First of all, I have a listbox. There could be more than one items in the listbox. I want save all those items in the listbox and then display them in a picture box at the end. The problem is that i cannot print the items in the picture box at the same time when the listbox is populated, because the items in the listbox fall under one of the items in another listbox.
Could you help me with this.

Msg All Listview Items
hi i am wanting to display a message box for each item in a listview. the code i currently have is:

Public Sub msgALL()
Dim i As Integer
For i = 0 To lstSYS.ListItems.Count - 1
MsgBox lstSYS.SelectedItem
Next i
End Sub

this only displays the first item as the code states to display the selected item. how can i make it cycle through?

thanks

Getting Listview Items
Hi!

i would like to retrieve the item text selected (by double clicking) in a listview.

How can I do?

Thanks

sonia

Listview Add Items
Hi, I have a Listview in my project and I would like to know how can I add all the text of the listview column to specific field name in my database Access. What Can I do? This is the code to add info to my Database:


Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = OpenDatabase(App.Path & "Base de DatosPros2003.mdb")
With db Set rs = .OpenRecordset("Tratamientos Pacientes")
End With

On Error Resume Next
With rs
.AddNew
!ID = Text2.Text
!Precio = txtTotalAmount.Text
!Usuario = txtCheckedBy.Text
!Codigo = txtProdCode.Text
!Tratamiento = Listview1.WHAT CODE I NEED TO ADD HERE?
!Descuento = txtDiscount.Text
!Tratamiento = txtDescription.Text
!Cantidad_Pagada = txtCash.Text
!Numero_Cheque = txtCheckNumber.Text
!Banco = txtBank.Text
.Update
.close
MsgBox "Congratulations", vbOKOnly + vbDefaultButton1, "Pro 2003"
End With

THANKS A LOT.

Same Items In Listview
Hello... I have one problem.

I fill the listview with some standard sql query.
SELECT Name FROM ...

If there are few same names, then they are all filled down.
Now, I want this:

if there are some names that they are exatcly the same I want just first one to be writed down, then the next different name and so on...

Is this possible?

Get ListView Items From Other App's
i need to get Item texts of a ListView control that we know it's hwnd from other applications.
we can easily send LVM_GETITEMTEXT message to the listview object and retrive any item. but i want to get items of a listview in another application and when i call sendmessage in this case, my program fail and close by windows. i think this is because of memory access or something like that. may other applications doesn't have access to the memory buffer of my program.
note that i can get list count (number of items) by sending LVM_GETITEMCOUNT message and it has no problem but i can't get text of items.

here is the basic code to retrive an item in vb (it works if you call it for listview controls that exists on your program and not other windows applications)

thanks
s.serp.

--------------------------- Module LVAPI.bas

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const LVM_FIRST = &H1000 ' ListView messages
Public Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Public Const LVM_GETITEMTEXTA = (LVM_FIRST + 45) 'unicode
Public Const LVM_GETITEMTEXTW = (LVM_FIRST + 115)

Public Type LVITEM
mask As Long
iItem As Long
iSubItem As Long
State As Long
stateMask As Long
pszText As Long 'String
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long 'for IE>3
End Type

Function GetListViewText(ByVal hwnd As Long, ByVal ItemIndex As Long) As String
' Obtain the name of the specified Item of the list view
On Error Resume Next
Dim objItem As LVITEM
Dim baBuffer(320) As Byte, n As Long
With objItem
.mask = LVIF_TEXT
.iSubItem = 0
.pszText = VarPtr(baBuffer(0))
.cchTextMax = UBound(baBuffer) - 1
End With
n = SendMessage(hwnd, LVM_GETITEMTEXTA, ItemIndex - 1, objItem) ' ItemIndex-1 is because of list is zero-based index
GetListViewText = Left$(StrConv(baBuffer, vbUnicode), n) 'convert from binary byte array to a String
End Function

Function GetListViewCount(ByVal hwnd As Long) As Long
'this simply get number of items
GetListViewCount = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, ByVal 0)
End Function


---------------------- Form1

Private Sub Form_Load()

With ListView1
.View = lvwReport
.ColumnHeaders.Add Text:="Name"
.ListItems.Add Text:="John"
.ListItems.Add Text:="Kharazmi"
.ListItems.Add Text:="ABCD"
.Refresh
End With

Label1.Caption = "N = " & GetListViewCount(ListView1.hwnd)
Label2.Caption = "Item 1 = " & GetListViewText(ListView1.hwnd, 1)
Label3.Caption = "Item 3 = " & GetListViewText(ListView1.hwnd, 3)

'The Problem is that we can't call this way for ListView controls of other applications!

End Sub

Need Help In ListView Items
Hi All
i use this code to add an item to listview


VB Code:
Dim itmX As ListItemSet itmX = ListView1.ListItems.Add(, , "aaaaaaa")    itmX.SubItems(1) = Time    itmX.SubItems(2) = Date

it add new item in the last row
how to add item in order newst item is in first row


thanx

Items In A ListView
I have a combobox which acts as a Lookup table, a command button and a ListView. My aim is that when i select an item from the combo, on clicking the command button, the selected item from the combo gets listed in the ListView. The code for filling the combo is :
VB Code:
Dim strSQL As String    'Declare the variables we need                   strSQL = "SELECT movieId, title FROM movieInfo"  Set rsMovie = New ADODB.Recordset         rsMovie.Open strSQL, cnAddMovie, adOpenForwardOnly, adLockReadOnly, adCmdText    With cboTitle        .Clear            Do While Not rsMovie.EOF        .AddItem rsMovie.Fields("title").Value        .ItemData(.NewIndex) = rsMovie.Fields("movieId").Value          rsMovie.MoveNext    Loop      End With   rsMovie.Close  Set rsMovie = Nothing


BUT now when the selected item is listed in the ListView, I want the following code executed.

VB Code:
'strSQL = "SELECT movieInfo.movieId, movieInfo.title, MediaType.StrKey, MediaType.DefRentPricePerDay, MediaType.DefRentPeriodInDays FROM movieInfo INNER JOIN MediaType ON movieInfo.media_catId = MediaType.media_catId WHERE movieId = " & cboTitle.ItemData(cboTitle.ListIndex)  


So that in the ListView, I have columnsheaders showing Movie title, Format, rentPrice etc

How can i do that?

Listview Max Items
Can someone please tell me what is the maximum number of items in the list with Listview?

My program searches a database with thousands of records and reports errors and I would like to be able to list them on the screen so the end user can review.(Printing them out is another story) A listbox runs out at about 32k items.
I would only need 4 colums in the listview.
If anyone has any ideas on what or how I can do this , I am all ears...

Thanks in Advance

Trent

Get Listview Items
Is it possible to save all the items in another apps listview?

Listview Items
How do I give items in a listview a tag?

Getting Sum Of Items In Listview......
Ok, I got a response to a question similar to this before, but for some reason, I couldn't even modify the code to work, and kept getting an object required error. Maybe it had something to do with my use of the listview control Anyway, I'll be more specific this time. Here goes.

Listview2:

In the main column is text, and in subitem1 column is a number (i.e 2:30)

What I want to do is on a command1_click() get the sum of all the numbers in listview2 subitem1, and set that = to sum

Then let listview3.listitems.add SUM


Hope that makes sense. Anway since there is a ":" in the number, it must currently be formatted as a string and not an integer right? So, what do I need to do to total up all of these numbers? Any help is greatly appreciated.

Listview Items....
Hey peops, I was wondering if there was anyone out there that could tell me how to disable editing within a listview's columns...What I'm doing is connecting to an Oracle DB and pulling data and then putting that recordset data onto my listview so i can view them like a spreadsheet (obviously). The problem is that when i click on an item and hold down the mouse button long enough, I'm able to edit the first column...I want to disable this ability. Basically i want none of the recordset data to be renamed or changed, but the items can be selected...thanks in advance

Add Items To ListView?
I have the code below which puts two column headers at the top of my ListView control, (Title) and (Description). . .


Code:

Private Sub Form_Load()

Me.ListView1.View = lvwReport

Me.ListView1.ColumnHeaders.Clear
Me.ListView1.ColumnHeaders.Add , , "Title", ListView1.Width / 2
Me.ListView1.ColumnHeaders.Add , , "Description", ListView1.Width / 2
End Sub



Can anyone show me the code I can add to this that will add one item in the list view control with the text (Item Title) under the ‘Title’ column and (Item Description) under the ‘Description’ column?


.

Moving Through Items In A Listview
Am I being a complete , or what? I'm trying to move through the items in a listview, so that I can insert the entries one-by-one in to DB - ie each item in the listview represents a new record in a DB table.

Now, I would have expected (as with all things VB) this to be quite straight forward. Something along the lines:

ListView1.selecteditem.movenext

I know this a bit hopeful, but I can't believe there's no way to incrementally move through all the items.

I've been through MSDN and searched this entire forum for a similar thing but I cant find anything.

I must be missing something really obvious here!

Highlighting Items In Listview...
I have this small application that has a listview wherein it gets populated by database records. My DB table is arranged alphabetically so it will also be arranged in the listview as well. But I'm haveing trouble displaying/highlighting the last item that was entered in the table so the user will have to scroll through the whole listview to see if what they entered did go in since the table is arranged alphabetically. The display type of my listview is in lvwReport by the way. Is there anyway I can do this?

Listview Items To Excel...
I was just wondering, is it possible to export the listview items to excel? If so, would it also be possible to export the selected items only?

ListView Adding Items.
Code:
Private Sub Form_Load()

With ListView1
.ColumnHeaders.Add Text:="Server"
.ColumnHeaders.Add Text:="Ram"
.ColumnHeaders.Add Text:="CPU"
.ColumnHeaders.Add Text:="C:"
.ColumnHeaders.Add Text:="Ping"
.View = lvwReport
End With



End Sub
i have this code to give the listview1 5 diffrent columns.

can someone give me the code that when command1 is clicked, it will add a row underneath the columns in this order:

server1
ram1
cpu1
c:1
ping1

just so i know how to do this.

Swap Items In Listview
Hello I have a scenario here.
I have a Listview and two command butons (up and down)
Initial Listview Items

A text1 text1
B text2 text2
C text3 text3 - Selected

now when the Up button this is what will happen

A text1 text1
C text3 text3 - Selected
B text2 text2

Hope someone here help me.

Thanks

Search Through ListView Items
pls can anyone show me how to search through listview items

for example - find a specific text in a ListView

Adding N Items Into ListView
I am using following code to add records read from a text file into a ListView object.


Code:
Dim S
Dim SP
Dim i
Dim LItem As ListItem

i = 1
Open App.Path & "dataspdates.txt" For Input As #1

Do While Not EOF(1)
Line Input #1, S
SP = Split(S, "+", , vbTextCompare)

Set LItem = ListView1.ListItems.Add(, , SP(0))
LItem.SubItems(1) = SP(1)
i = i + 1
Loop
Close #1
My ListView Control has just two columns, and the text file contains records like:

3/10/04+Mr.D Birthday
6/1/04+Mr.C.Anniversary

In the above code, SP will store the splitted line read from the file. The problem is that the above code displays an error "Subscript out of range", at the line starting with "Set LItem".
How to keep adding records to ListView till EOF.

Copyright © 2005-08 www.BigResource.com, All rights reserved