Display SQL DB data in VB scripted page... HELP!
Imports Microsoft.VisualBasic
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class DBAccess
Dim connectionstring As String = "Server=localhost;Database=geustdb;Uid=*********** ;Pwd=***********"
Public Function SQLCommandNoResults(ByVal command As MySql.Data.MySqlClient.MySqlCommand) As Boolean
Dim connection As New MySql.Data.MySqlClient.MySqlConnection
connection.ConnectionString = connectionstring
connection.Open()
command.Connection = connection
command.ExecuteNonQuery()
Return True
End Function
End Class
----------------------------------------------------------------------
I have my data going to the table:
Protected Sub infosubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles infosubmit.Click
'Dim connection As New MySql.Data.MySqlClient.MySqlConnection
'connection.ConnectionString = "Server=localhost;Database=geustdb;Uid=*********** ;Pwd=***********"
'connection.Open()
Dim dba As New DBAccess
Dim command As New MySql.Data.MySqlClient.MySqlCommand
command.CommandText = "INSERT INTO guest_info (firstname, lastname, email, msgdate, poll, msgbody) VALUES (@firstname, @lastname, @email, @msgdate, @poll, @msgbody)"
command.Parameters.AddWithValue("firstname", firstnamebox.Text)
command.Parameters.AddWithValue("lastname", lastnamebox.Text)
command.Parameters.AddWithValue("email", emailbox.Text)
command.Parameters.AddWithValue("msgdate", DateTime.Now())
command.Parameters.AddWithValue("poll", Poll.SelectedValue)
command.Parameters.AddWithValue("msgbody", commentbox.Text)
Dim A As Boolean = dba.SQLCommandNoResults(command)
Response.Redirect("Default2.aspx")
------------------------------------------------------------------------
I BELIEVE I am pulling the data back out into the MySqlDataAdapter:
Public Function SQLCommandWithResults(ByVal command As MySql.Data.MySqlClient.MySqlCommand) As DataTable
Dim connection As New MySql.Data.MySqlClient.MySqlConnection
Dim da As MySqlDataAdapter
Dim dt As New DataTable
connection.ConnectionString = connectionstring
connection.Open()
command.Connection = connection
da = New MySqlDataAdapter(command)
da.Fill(dt)
Return dt
End Function
-----------------------------------------------------------------------
But now I dont know how to get it to display in Default2.aspx in the
**
<aspanel ID="pnlGuest" runat="server">
</aspanel>
**
tag... Or anywhere else for that matter... I have looked everywhere and can find nothing to help me get the data onto the page. It is a guestbook which contains rows in the database that I do not want displayed on the webpage. But I just dont know what Im doing. This is my first ever project on anything other than HTML so I am learning the hard way. ANY HELP WOULD BE GREATLY APPRECIATED!!!
-
BrianLeanza -
[ 1 ] Thanks
{{ DiscussionBoard.errors[1637538].message }} -
-
Mr. Enthusiastic -
[ 1 ] Thanks
{{ DiscussionBoard.errors[1638499].message }} -
-
localbandpost -
Thanks
{{ DiscussionBoard.errors[1714188].message }} -