|
-
Mar 26th, 2008, 01:54 PM
#1
Thread Starter
Lively Member
[2008] Need help adding content from textbox to mysql database
Hello, im working on an application that allows you to create a login. It's suppose to add the content from textbox 1 as your username, the content from textbox 2 as your password.
So far this is what i got
Code:
Imports System.Data.SqlClient
Public Class Form1
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim ra As Integer
'integer holds the number of records inserted
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
End Sub
Public Function RandomNumber(ByVal MaxNumber As Integer, _
Optional ByVal MinNumber As Integer = 0) As Integer
Dim r As New Random(System.DateTime.Now.Millisecond)
If MinNumber > MaxNumber Then
Dim t As Integer = MinNumber
MinNumber = MaxNumber
MaxNumber = t
End If
Return r.Next(MinNumber, MaxNumber)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Accountname As String
Dim Password As String
Dim Accountdetails As String
Accountname = Accname.Text
Password = Pwd.Text
Accountdetails = " Accountname: " & Accountname & " Password: " & Password
MsgBox("Please wait a moment")
myConnection = New SqlConnection("server=localhost;uid=root;pwd=xxxxxx;database=logon")
myConnection.Open()
myCommand = New SqlCommand("Insert into Accounts values 7," & Accountname & "," & Password & ",0,0,null,null,null,8")
ra = myCommand.ExecuteNonQuery()
'MsgBox("New Row Inserted" & ra)
myConnection.Close()
MsgBox("Your account has been created your details is as following:" & Accountdetails)
End Sub
End Class
Also at "insert into accounts values 7," i would like the 7 to be an random number (because its suppose to work with more than one entry.)
How would i go about getting this to actually connect to the database? and make the 7 be an random generated number, ive been googling for ages, i simply cant find what im looking for.
All help will be very appreciated,
Sincerely
Kolklik
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
|