Archive for Tháng Chín 10, 2008

Select SQL Column name contains “.” characters

Select [Co#lumn] from myTable

Tháng Chín 10, 2008 at 6:05 sáng Để lại phản hồi

Export Data to CSV file

Private Sub SaveGridDataInFile(ByRef fName As String)
Dim I As Integer = 0
Dim j As Integer = 0
Dim cellvalue$
Dim rowLine As String = “”
Try
Dim objWriter As New System.IO.StreamWriter(fName, True, System.Text.Encoding.Default)
For j = 0 To (DataGridView1.Rows.Count – 2)
For I = 0 To (DataGridView1.Columns.Count – 1)
If Not TypeOf DataGridView1.CurrentRow.Cells.Item(I).Value Is DBNull Then
cellvalue = DataGridView1.Item(I, j).Value.ToString
Else
cellvalue = “”
End If
rowLine = rowLine + cellvalue + “,”
Next
objWriter.WriteLine(rowLine)
rowLine = “”
Next
objWriter.Close()
MsgBox(“保存ファイル成功”)
Catch e As Exception
MessageBox.Show(“Error occured while writing to the file.” + e.ToString())
Finally
FileClose(1)
End Try
End Sub

Tháng Chín 10, 2008 at 1:05 sáng Để lại phản hồi

Add Rows Index to datagridview

Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
If e.ColumnIndex < 0 AndAlso e.RowIndex >= 0 AndAlso e.RowIndex < datatabel(1).Rows.Count Then
e.PaintBackground(e.ClipBounds, True)
e.Graphics.DrawString((e.RowIndex + 1).ToString, Me.Font, Brushes.Black, e.CellBounds, sf)
e.Handled = True
End If
End Sub

Tháng Chín 10, 2008 at 1:03 sáng Để lại phản hồi


 

Tháng Chín 2008
T2 T3 T4 T5 T6 T7 CN
« Tháng 8   Tháng 10 »
1234567
891011121314
15161718192021
22232425262728
2930  

Follow

Get every new post delivered to your Inbox.