[help]with databases i guess.

Posts 17 of 7 · Page 1 of 1
[help]with databases i guess.
i guess this is a simple question(for those people who are "warriors" of the vb section)
lets say i have 2 textboxes and a button, and in one of the textboxes u put "trevor"(or w/e ur name is) and then press the button it will go on your database, and then the other text box shows all the names that have been submitted before so in that text box it would show like.

trevor
othername
othername
othername

if u can help thanks if not...well nuthin.
You should learn about SQL or MySQL (w/e) queries... (SELECT)
Download MySQL Connector for .Net (Google).

Add the .dll from Installed folder\bin\net 2.0 as reference...

[php] Private conn As New MySqlConnection
Private Const connstr As String = "server=Your IP;" & "user id=username;" & "password=password;" & "database=database name"
Private reader As MySqlDataReader[/php]

[php] Private Sub InsertName()
Dim strSQL As String = ""

conn = New MySqlConnection(strConn)
conn.Open()

strSQL = "INSERT INTO Table(Column) VALUES('" & Textbox1.text & "')"

Dim cmd As New MySqlCommand(strSQL, conn)
cmd.ExecuteNonQuery()

conn.Close()

MsgBox("Your name has been added to the database." MsgBoxStyle.Information, "Success")

Catch ex As MySqlException
conn.Close()
End Try

GetNames()

End Sub[/php]

[php]Private Sub GetNames

Dim strConn As String = connstr
Dim strSQL As String = "SELECT * FROM Table'"

conn = New MySqlConnection(strConn)
conn.Open()

Dim cmd As New MySqlCommand(strSQL, conn)
reader = cmd.ExecuteReader

Do While reader.Read
Textbox1.Text &= reader("Column") & vbNewLine
Loop

reader.Close()
End Sub[/php]

Button_Click

[php]Dim t as new threading.thread(addressof InsertName)
t.priority = threading.thread.priority.highest
t.start[/php]


I just fully wrote this up for you...Feel free to copy & paste...

Keep in mind that you have to change:

-Column
-Table
-Textbox1.Text
I wouldn't give him that code AGAIN. =P
Quote Originally Posted by Blubb1337 View Post
I wouldn't give him that code AGAIN. =P
I just told him to learn a bit of SQL so it would be easier to understand what you wrote.. xd because i'm pretty sure he is clueless about queries and non-queries ofc i wouldn't rewrite the code.
Alright, he should...

INSERT INTO Table(Column,Column) VALUES ('Value','Value')

SELECT * FROM Table WHERE Column='Value' AND/OR Column='Value'

UPDATE Table SET Column='Value'

=P
Posts 17 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?