Click here to Skip to main content
15,896,528 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Creating a File Menu Pin
Colin Angus Mackay10-Jan-07 2:04
Colin Angus Mackay10-Jan-07 2:04 
QuestionHow to Get Execution Time Pin
suveenmohan9-Jan-07 23:15
suveenmohan9-Jan-07 23:15 
AnswerRe: How to Get Execution Time Pin
testy_proconsul9-Jan-07 23:56
testy_proconsul9-Jan-07 23:56 
Questionlistview problem ini vb.net 2005 Pin
amaneet9-Jan-07 23:10
amaneet9-Jan-07 23:10 
AnswerRe: listview problem ini vb.net 2005 Pin
johnny19639-Jan-07 23:49
johnny19639-Jan-07 23:49 
Questionlistview Pin
johnny19639-Jan-07 21:01
johnny19639-Jan-07 21:01 
AnswerRe: listview Pin
johnny196310-Jan-07 0:45
johnny196310-Jan-07 0:45 
GeneralRe: listview Pin
johnny196311-Jan-07 6:58
johnny196311-Jan-07 6:58 
the folowing works perfect. I you want only columns you want to select from your datbase, write ("SELECT [fistname],[backname] from contacten") inplace of ("SELECT * FROM contacten")


Public Class Form1



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myCon As SqlClient.SqlConnection
Dim sqlCmd As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT * FROM contacten")
Dim myData As SqlClient.SqlDataReader

Dim lvhHelper As ListViewData = New ListViewData()

myCon = New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\contactpersonendata.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")


Try
myCon.Open()
sqlCmd.Connection = myCon
myData = sqlCmd.ExecuteReader
lvhHelper.FillListView(ListView1, myData)
myCon.Close()
Catch eSql As System.Data.SqlClient.SqlException
MessageBox.Show(eSql.ToString)
End Try




End Sub
---------------------------------------------------------------

End the class:

Imports System.Data.SqlClient

Public Class ListViewData
Public Sub FillListView(ByRef MyListView As ListView, _
ByRef myData As SqlDataReader)
Dim lvwColumn As ColumnHeader
Dim itmListItem As ListViewItem
Dim strtest As String


Dim shtCntr As Short

MyListView.Clear()
For shtCntr = 0 To myData.FieldCount() - 1
lvwColumn = New ColumnHeader()
lvwColumn.Text = myData.GetName(shtCntr)
MyListView.Columns.Add(lvwColumn)
Next

Do While myData.Read
itmListItem = New ListViewItem()
strTest = IIf(myData.IsDBNull(0), "", myData.GetValue(0))
itmListItem.Text = strTest


For shtCntr = 1 To myData.FieldCount() - 1
If myData.IsDBNull(shtCntr) Then
itmListItem.SubItems.Add("")
Else
itmListItem.SubItems.Add(myData.GetString(shtCntr))
End If
Next shtCntr

MyListView.Items.Add(itmListItem)
Loop
End Sub
End Class

Questionglobalization/localization Pin
tawiskid099-Jan-07 19:50
tawiskid099-Jan-07 19:50 
AnswerRe: globalization/localization Pin
testy_proconsul9-Jan-07 21:24
testy_proconsul9-Jan-07 21:24 
QuestionGet and Set property in vb.net Pin
amaneet9-Jan-07 19:24
amaneet9-Jan-07 19:24 
AnswerRe: Get and Set property in vb.net Pin
Christian Graus9-Jan-07 20:24
protectorChristian Graus9-Jan-07 20:24 
AnswerRe: Get and Set property in vb.net Pin
Guffa9-Jan-07 22:51
Guffa9-Jan-07 22:51 
AnswerRe: Get and Set property in vb.net Pin
Dave Kreskowiak10-Jan-07 5:09
mveDave Kreskowiak10-Jan-07 5:09 
QuestionI want to get the .txt and .Doc file's contents. Pin
somagunasekaran9-Jan-07 19:08
somagunasekaran9-Jan-07 19:08 
AnswerRe: I want to get the .txt and .Doc file's contents. Pin
Christian Graus9-Jan-07 20:27
protectorChristian Graus9-Jan-07 20:27 
GeneralRe: I want to get the .txt and .Doc file's contents. Pin
somagunasekaran9-Jan-07 23:33
somagunasekaran9-Jan-07 23:33 
GeneralRe: I want to get the .txt and .Doc file's contents. Pin
Christian Graus10-Jan-07 0:22
protectorChristian Graus10-Jan-07 0:22 
QuestionMy.Settings question Pin
sa_runner9-Jan-07 19:06
sa_runner9-Jan-07 19:06 
AnswerRe: My.Settings question Pin
Johan Hakkesteegt11-Jan-07 3:37
Johan Hakkesteegt11-Jan-07 3:37 
Questiondatabase tables search in vb.net Pin
amaneet9-Jan-07 18:42
amaneet9-Jan-07 18:42 
AnswerRe: database tables search in vb.net Pin
testy_proconsul10-Jan-07 0:00
testy_proconsul10-Jan-07 0:00 
GeneralRe: database tables search in vb.net Pin
amaneet10-Jan-07 0:35
amaneet10-Jan-07 0:35 
GeneralRe: database tables search in vb.net Pin
testy_proconsul10-Jan-07 1:25
testy_proconsul10-Jan-07 1:25 
QuestionStrange FileWatch problem? Pin
rudemusik9-Jan-07 18:00
rudemusik9-Jan-07 18:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.