15,898,035 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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
Buena Velasco
8-Jul-11 7:02am
View
Thanks OriginalGriff! i guess this is the part i didn't get immediately.. I've tried it but no data has appeared. The add-function's working, I really don't know what's wrong with it.
Buena Velasco
5-Jul-11 3:42am
View
Thanks Mr. Graus, I'm able to solve it, took out the other connection string and then added cmd.ExecuteNonQuery. :)
<pre>
<pre lang="vb">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
Dim connection As New MySqlConnection("Server = localhost; User Id = root; Password = root; Database = add_edit_delete")
connection.Open()
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 = connection
cmd.ExecuteNonQuery()
MsgBox("Record has been saved!", MsgBoxStyle.Information, "System Message")
connection.Close()
Me.Dispose()
Catch ex As Exception
MsgBox("Unable to save record!", MsgBoxStyle.Critical, "System Message")
connection.Close()
End Try
End If
End Sub</pre>
</pre>
Show More