🔒 Closed Need help vb2010 ordering

Status
Not open for further replies.

Saycheeseter

Enthusiast
Guys pa help naman po ako dto sa system ko sa sunday na po deadline eh. ung pag nag order po ako lahat mapupunta sa listview pero po ang nangyayare napupunta nga lahat sa listview pero pag sinave ko isa lang nasasave hindi kasama ung iba.
 

Attachments

  • proj.webp
    proj.webp
    41.9 KB · Views: 19
Try
For Each item As ListViewItem In LV.Items
str = "INSERT INTO ordering ([Name],[Phone],[Description],[Quantity],[Price],[Total]) values (?,?,?,?,?,?)"
Dim cmd As OleDbCommand = New OleDbCommand(str, Con)
cmd.Parameters.AddWithValue("name", txtname.Text)
cmd.Parameters.AddWithValue("phone", txtphone.Text)
cmd.Parameters.AddWithValue("@Description", item.Text)
cmd.Parameters.AddWithValue("@Quantity", item.SubItems(1).Text)
cmd.Parameters.AddWithValue("Price", item.SubItems(2).Text)
cmd.Parameters.AddWithValue("@Tota;", item.SubItems(3).Text)

cmd.ExecuteNonQuery()
cmd.Dispose()
MsgBox("Successfully")


Next

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try


eto po code ko para sa save button mga sir.
 
Iloop mo yung insert function mo. ex:
Code:
For index as Integer = 0 to Listview1.items.count step 1
 con.open()
 str = "INSERT INTO ordering (name,.....) VALUES (@name, .....)"
 Dim cmd as OleDbCommand = New OleDbCommand(str, Con)
 cmd.Parameters.AddWithValue("@name", txtname.Text)
...... // Jump na ko sa quantity
 cmd.Parameters.AddWithValue("@Quantity", item.SubItems(index).Text)
 cmd.Parameters.AddWithValue("@Price", item.SubItems(index).Text)
 cmd.Parameters.AddWithValue("@Total", item.SubItems(index).Text)

cmd.ExecuteNonQuery();

con.close()

Next

Note: ginaya ko lang code mo, dinagdagan ko lang ng for loop, tapos yung parameter ng SubItems() ginawa kong variable na index (yung nasa for loop). Then lagi mo icclose yung connection every insert.

Ps. Not sure kung working to. Di ko naman kasi natry hahaha but the idea is there, explore mo nalang
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 390
    Views
  • 3
    Participants
Last reply from:
Mrkmrk

Trending Topics

Online now

Members online
1,057
Guests online
1,016
Total visitors
2,073

Forum statistics

Threads
2,274,732
Posts
28,957,871
Members
1,233,410
Latest member
glennmart0525
Back
Top