Dim connStr as String = "Server= Local; Initial Catalog = YourDataBase; UId=YouUserName; Pwd= YourPassword"
Dim conn as new SQLCLient.SqlConnection(connStr)
Conn.open()
CmdStr As String = "SELECT Naam, Lidnr, Adres, Voornaam, Postcode, Gemeente " & _ " FROM tblLeden WHERE Lidnr = " & YOUR_VARIABLE
Dim cmd as new SQLClient.SqlCommand (cmdStr, conn)
Dim dr as SqlClient.SqlDataReader = cmd.ExecuteReader
While Dr.Read StrLidnr = dr.GetString(0) 'index of the column or I don't remember very well but you can also write the colum name like dr.GetString("Lidnr")
StrAdres = dr.GetString("Adres") ' or StrAdres= dr.getString(2)
StrPostCode = dr.GetString("Postcode") 'According the data type you can ask GetByte or GetDate
End While
Conn.close()
If you do not have a connection string how did you manage to excute the query you mentioned in your post
Are you using a typed dataset
If it is the case, than you already have your connection created, you have your typed data tables and table adapters. If it is the case you must have a table adapter called " tblLedenTableAdapter" and you must have a table called "tblLedenDataTable"
so you can use this objects like
Dim mLedenAdapter As New tblLedenTableAdapter Dim mLedenTable As New LadenDataTable = mledenAdpater.GetData()
Dim mLedenRow as tblLedenRow
For each mLedenRow in mLedenTable.Rows
strNaam = mLedenRow.Naam strAdres = mLedenRow.Adres ad so on...
Next
|