Hello all,
I'm a vb6 programmer who has finally committed to move to .Net and I'm starting my first project. I'm using VB 2005 and mySQL for the database. I've so far been able to load data into a datatable or dataset but I don't know how to access the data in it. In vb6 I would use the .fields("fieldname") on a recordset. I have two questions:
1) If I'm retrieving data from a table and want to manually play with it should I use a dataset or datatable to load the data into?
2) For both a dataset and a datatable, how do I reference the field contents of a record?
Any guidance or reference would be really appreciated.
Here is what I have so far:
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmLogin
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myDataSet As New DataSet
Dim strSQL As String
Dim myConnString As String
'Open the Database
Try
'conn = New MySqlConnection
myConnString = "server=localhost; user id=user; password=pw; database=mydatabase"
conn.ConnectionString = myConnString
strSQL = "SELECT * FROM Security WHERE loginID ='" & txtUserName.Text & "'"
myCommand.CommandText = strSQL
myAdapter.SelectCommand = myCommand
myAdapter.SelectCommand.Connection = conn
myAdapter.Fill(myDataSet)
conn.Close()
If Not myDataSet.WHAT GOES HERE? = txtPassword.Text Then ...
Thanks.
I'm a vb6 programmer who has finally committed to move to .Net and I'm starting my first project. I'm using VB 2005 and mySQL for the database. I've so far been able to load data into a datatable or dataset but I don't know how to access the data in it. In vb6 I would use the .fields("fieldname") on a recordset. I have two questions:
1) If I'm retrieving data from a table and want to manually play with it should I use a dataset or datatable to load the data into?
2) For both a dataset and a datatable, how do I reference the field contents of a record?
Any guidance or reference would be really appreciated.
Here is what I have so far:
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmLogin
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myDataSet As New DataSet
Dim strSQL As String
Dim myConnString As String
'Open the Database
Try
'conn = New MySqlConnection
myConnString = "server=localhost; user id=user; password=pw; database=mydatabase"
conn.ConnectionString = myConnString
strSQL = "SELECT * FROM Security WHERE loginID ='" & txtUserName.Text & "'"
myCommand.CommandText = strSQL
myAdapter.SelectCommand = myCommand
myAdapter.SelectCommand.Connection = conn
myAdapter.Fill(myDataSet)
conn.Close()
If Not myDataSet.WHAT GOES HERE? = txtPassword.Text Then ...
Thanks.