Click here to Skip to main content
15,904,497 members

Comments by Hendi Hermawan (Top 4 by date)

Hendi Hermawan 23-Sep-16 1:28am View    
ok, thnx for ur advice mika :) , ill try then... :)
Hendi Hermawan 22-Sep-16 23:42pm View    
yes true mika, im fetch data into single string variable and use a comma as delimiter between items.

im still confused mika :)

if this can be solved, this maybe be great idea for create very dynamic datagridview. just 1 form and 1 datagrid will be create a lot of report :)
Hendi Hermawan 22-Sep-16 23:27pm View    
thnx mika for ur answer but thats not my solution, this my full code, i hope u will understand with my code :)

Sub caridata()

dt.Clear()
Call koneksi()
Dim SqlQuery As String = "SELECT * FROM " & Label4.Text & " where Tanggal >= @dtawal and tanggal <= @dtakhir"
With cmd
.Parameters.AddWithValue("@dtawal", Format(DateTimePicker1.Value, "yyyy-MM-dd"))
.Parameters.AddWithValue("@dtakhir", Format(DateTimePicker2.Value, "yyyy-MM-dd"))
.CommandText = SqlQuery
.Connection = conn
End With
With adapter
.SelectCommand = cmd
.Fill(dt)
End With
Try
Call koneksi()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = "select * from tbllaporan2 where [caption form]='" + Me.Text + "'"
Cari2 = cmd.ExecuteReader
If Cari2.HasRows = True Then
Cari2.Read()
Dim asalfield, arrow(), union As String

asalfield = Cari2("Asal Field")
arrow = asalfield.Split("|")
DataGridView1.Rows.Clear()
With DataGridView1
For a As Integer = 0 To arrow.Length - 2
union = union + " dt.Rows(i)(""" + arrow(a) + """),"

Next
MsgBox(Len(union))

End With
For i = 0 To dt.Rows.Count - 1
Dim t = Len(union) - 1
Dim z As String = Microsoft.VisualBasic.Left(union, t)

'MsgBox(z)
DataGridView1.Rows.Add(z)
'dt.Rows(i)("Nomor"), dt.Rows(i)("Tanggal"), dt.Rows(i)("Nama Tercetak"), dt.Rows(i)("Qty"), dt.Rows(i)("Harga"), dt.Rows(i)("Jumlah"), dt.Rows(i)("Paid Status")
Next

cmd.Parameters.Clear()

Else
Label4.Text = ""
End If
conn.Close()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Hendi Hermawan 22-Sep-16 22:34pm View    
is there any way that the string can be executed in rows.add ()?

I want to string sql query result of which I keep in a string z can execute in rows.add ()

thnx for ur help Dave