|
-
Dec 22nd, 2011, 11:01 AM
#1
Thread Starter
Addicted Member
reading content in a mysql database
I looked everywhere online and I couldn't locate an equivalent VB2008 code for this php code.
$field = mysql_fetch_assoc($result);
$field_title=$field["title"];
I'm trying to read the content of a field in a mysql database. I found this code below that does it but you must select the position of the field (column 0, 1, 2 etc) myData.GetString(1) instead of the name of the field. In the php code above it is "title". I'm looking for a command like myData.GetString("title")
Any help would be appreciated.
Sam
********************
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myData As MySqlDataReader
Dim SQL As String
Dim table_name As String = "website_products"
SQL = "SELECT * FROM " & table_name & " WHERE `idnum` = '2'"
myCommand.Connection = conn
myCommand.CommandText = SQL
myAdapter.SelectCommand = myCommand
Try
myData = myCommand.ExecuteReader()
myData.Read()
MsgBox(myData.GetString(1))
myData.Close()
Catch ex As MySqlException
MsgBox(ex.Message)
End Try
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|