Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

listview vb.net menggunakan MySQL

halo kk, saya newbie neh. saya make vb.net dan db nya MySQL

jadi saya bikin form_1 yang isinya textbox2, lalu ketika gt saya klik save dia tersimpan dan db dan ketika saya buka form_dblist, nnt ada listview data2 yang saya masukkan, Nah, codenya saya buat seperti ini<div class='geshi_syntax'><table><tr><td><div class='code'><pre class="vbnet"><span class="kw2">Public</span> <span class="kw6">Sub</span> list_data<span class="br0">(</span><span class="br0">)</span>
<span class="kw6">Dim</span> sql <span class="kw2">As</span> <span class="kw2">String</span>
<span class="kw6">Dim</span> x <span class="kw2">As</span> <span class="kw4">Integer</span>
 
<span class="kw6">Try</span>
conn <span class="sy0">=</span> <span class="kw2">New</span> MySqlConnection<span class="br0">(</span><span class="br0">)</span>
conn <span class="sy0">=</span> <span class="kw2">New</span> MySqlConnection<span class="br0">(</span><span class="st0">"server="</span> <span class="sy0">&</span> MySQLServer <span class="sy0">&</span> <span class="st0">";user="</span> <span class="sy0">&</span> MySQLUser <span class="sy0">&</span> <span class="st0">";database="</span> <span class="sy0">&</span> MySQLDatabase <span class="sy0">&</span> <span class="st0">";"</span><span class="br0">)</span>
 
conn.<span class="kw6">Open</span><span class="br0">(</span><span class="br0">)</span>
sql <span class="sy0">=</span> <span class="st0">"select cabang,koor_cabang,korwil,penilik,nm_ktp,notes from tadd"</span>
cmmd <span class="sy0">=</span> <span class="kw2">New</span> MySqlCommand<span class="br0">(</span>sql, conn<span class="br0">)</span>
dt_reader <span class="sy0">=</span> cmmd.<span class="me1">ExecuteReader</span>
 
<span class="kw6">While</span> dt_reader.<span class="me1">Read</span> <span class="sy0">=</span> <span class="kw1">True</span>
x <span class="sy0">=</span> <span class="kw7">Val</span><span class="br0">(</span>FormDbFA.<span class="me1">txt_counter</span>.<span class="me1">Text</span><span class="br0">)</span>
FormDbFA.<span class="me1">txt_counter</span>.<span class="me1">Text</span> <span class="sy0">=</span> <span class="kw7">Str</span><span class="br0">(</span><span class="kw7">Val</span><span class="br0">(</span>FormDbFA.<span class="me1">txt_counter</span>.<span class="me1">Text</span><span class="br0">)</span> <span class="sy0">+</span> <span class="nu0">1</span><span class="br0">)</span>
 
<span class="kw6">With</span> FormDbFA.<span class="me1">ListViewEx1</span>
.<span class="me1">Items</span><span class="br0">(</span>FormDbFA.<span class="me1">ListViewEx1</span>.<span class="me1">Items</span>.<span class="me1">Count</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">)</span>.<span class="me1">SubItems</span>.<span class="me1">Add</span><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>FormDbFA.<span class="me1">ListViewEx1</span>.<span class="me1">Items</span>.<span class="me1">Count</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">)</span>.<span class="me1">SubItems</span>.<span class="me1">Add</span><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>FormDbFA.<span class="me1">ListViewEx1</span>.<span class="me1">Items</span>.<span class="me1">Count</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">)</span>.<span class="me1">SubItems</span>.<span class="me1">Add</span><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>FormDbFA.<span class="me1">ListViewEx1</span>.<span class="me1">Items</span>.<span class="me1">Count</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">)</span>.<span class="me1">SubItems</span>.<span class="me1">Add</span><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>FormDbFA.<span class="me1">ListViewEx1</span>.<span class="me1">Items</span>.<span class="me1">Count</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">)</span>.<span class="me1">SubItems</span>.<span class="me1">Add</span><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>FormDbFA.<span class="me1">ListViewEx1</span>.<span class="me1">Items</span>.<span class="me1">Count</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">)</span>.<span class="me1">SubItems</span>.<span class="me1">Add</span><span class="br0">(</span><span class="st0">""</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">0</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">0</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">1</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">1</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">2</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">2</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">3</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">3</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">4</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">4</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">5</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">5</span><span class="br0">)</span>
.<span class="me1">Items</span><span class="br0">(</span>x<span class="br0">)</span>.<span class="me1">SubItems</span><span class="br0">(</span><span class="nu0">6</span><span class="br0">)</span>.<span class="me1">Text</span> <span class="sy0">=</span> dt_reader.<span class="me1">GetString</span><span class="br0">(</span><span class="nu0">6</span><span class="br0">)</span>
<span class="kw6">End</span> <span class="kw6">With</span>
<span class="kw6">End</span> <span class="kw6">While</span>
<span class="kw6">Finally</span>
dt_reader.<span class="kw7">Close</span><span class="br0">(</span><span class="br0">)</span>
<span class="kw6">End</span> <span class="kw6">Try</span></pre></div></td></tr></table></div>
tp error, mohon bantuan dari kk2 semua. Thx
Tagged:

Comments

Sign In or Register to comment.