Click here to Skip to main content
15,898,035 members

Comments by Buena Velasco (Top 7 by date)

Buena Velasco 26-Jul-11 22:23pm View    
hehe.. yeah.. it's got a closing " right after the </html> tag.. Where could be the problem then?
Buena Velasco 26-Jul-11 3:03am View    
What closing quote on the 2nd line? Sorry, I'm not that good with PHP yet.
Buena Velasco 8-Jul-11 10:21am View    
haha.. it feels great! I think this is the only time I'm really learning how to "program/code" in my 3 yrs. as an IT student.. THANKS SO MUCH! Gave ya 5. :) God bless you! :)
Buena Velasco 8-Jul-11 9:45am View    
Oooh! I did it!! YES! THANKS A LOT OriginalGriff! anyways, I found my error, add_edit_delete was my database, it should've been "register". SORRY!!!! But you helped me a lot fixing this. THANKS!!! :D solved! :)
Buena Velasco 8-Jul-11 7:53am View    
@Marcus Kramer, the add function definitely works.. I've checked it several times now, and it's totally working. :D it's the SELECT thingy I don't get, why it doesn't go the way it should be.

@Original Griff, nothing happens on the database even on the form. It just shows when I execute, no data appears even after I've added the function call. I'm trying to read the lines of codes over and over again. i hope I find the bug soon 'coz I really got no idea why it's like that.

HERE's the CODE (same code on module), I've added the HasRows and Read function:

Imports MySql.Data.MySqlClient
Public Class register
Private Sub register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
firstnametb.Focus()

Call Connection()
Try
strSql = "SELECT * FROM add_edit_delete;"
cmd.CommandText = strSql
cmd.Connection = conn
dadapter.SelectCommand = cmd

datardr = cmd.ExecuteReader

If datardr.HasRows Then
datardr.Read()
lastnametb.Text = datardr("LastName")
firstnametb.Text = datardr("FirstName")
middletb.Text = datardr("MiddleInitial")
agetb.Text = datardr("Age")
loctb.Text = datardr("Location")
unametb.Text = datardr("Uname")
pwordtb.Text = datardr("Pword")

conn.Close()
End If
Catch ex As Exception

End Try
End Sub

Private Sub addbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addbtn.Click
If lastnametb.Text = "" Or firstnametb.Text = "" Or agetb.Text = "" Or loctb.Text = "" Or unametb.Text = "" Or pwordtb.Text = "" Or cpwordtb.Text = "" Then
MsgBox("Please complete the fields!", MsgBoxStyle.Exclamation, "System Message")
Else
Call Connection()

Try
strSql = "INSERT INTO register(LastName, FirstName, MiddleInitial, Age, Location, Uname, Pword) VALUES('" & lastnametb.Text & "','" & firstnametb.Text & "','" & middletb.Text & "','" & agetb.Text & "','" & loctb.Text & "','" & unametb.Text & "','" & pwordtb.Text & "')"
cmd.CommandText = strSql
cmd.Connection = conn
cmd.ExecuteNonQuery()

MsgBox("Record has been saved!", MsgBoxStyle.Information, "System Message")
conn.Close()
Me.Dispose()
Catch ex As Exception
MsgBox("Unable to save record!", MsgBoxStyle.Critical, "System Message")
conn.Close()

End Try
End If
End Sub

Private Sub cancelbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancelbtn.Click
Me.Dispose()

End Sub
Private Sub clrbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clrbtn.Click
lastnametb.Text = ""
firstnametb.Text = ""
middletb.Text = ""
agetb.Text = ""
loctb.Text = ""
unametb.Text = ""
pwordtb.Text = ""
cpwordtb.Text = ""
End Sub
End Class