Click here to Skip to main content
15,913,722 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to seperate Letters, Numbers from a string? Pin
Paramu197320-Jan-10 22:12
Paramu197320-Jan-10 22:12 
AnswerRe: How to seperate Letters, Numbers from a string? Pin
Wayne Gaylard20-Jan-10 22:27
professionalWayne Gaylard20-Jan-10 22:27 
GeneralRe: How to seperate Letters, Numbers from a string? Pin
Paramu197320-Jan-10 22:35
Paramu197320-Jan-10 22:35 
GeneralRe: How to seperate Letters, Numbers from a string? Pin
Richard MacCutchan21-Jan-10 2:43
mveRichard MacCutchan21-Jan-10 2:43 
QuestionHow To Insert Username And Password Into MySql Using Vb.net's Form Pin
bernard tang20-Jan-10 20:27
bernard tang20-Jan-10 20:27 
AnswerRe: How To Insert Username And Password Into MySql Using Vb.net's Form Pin
Wayne Gaylard20-Jan-10 20:50
professionalWayne Gaylard20-Jan-10 20:50 
GeneralRe: How To Insert Username And Password Into MySql Using Vb.net's Form Pin
bernard tang20-Jan-10 22:46
bernard tang20-Jan-10 22:46 
GeneralRe: How To Insert Username And Password Into MySql Using Vb.net's Form [modified] Pin
Wayne Gaylard21-Jan-10 0:26
professionalWayne Gaylard21-Jan-10 0:26 
Okay, for the sake of simplicity I will assume you have a User class in your project with public properties UserName and Password. In this class you need to create a constructor that accepts a parameter for the username and one for the password (I would hope the password is encrypted) i.e

Public Sub New(ByVal Name As String, ByVal Pass As String)

        UserName = Name
        Password = Pass

    End Sub


You then need to create a function that saves your user i.e

Public Function SaveUser() As Integer

       Dim conDB As New MySqlConnection("server=localhost;uid=sa;pwd=;database=pubs")
       Dim myCon As New MySqlCommand
       myCon.CommandText = "INSERT INTO Users (Username, PassWord) VALUES (@Username,@Password)"
       myCon.Connection = conDB
       myCon.Parameters.AddWithValue("@Username", UserName)
       myCon.Parameters.AddWithValue("@Password", Password)
       Dim intResult As Integer = 0
       conDB.Open()
       intResult = myCon.ExecuteNonQuery
       conDB.Close()
       Return intResult

   End Function


in your Button.Click event you can just do this,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim newUser As New User(txtUserName.Text, txtPassword.Text)
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim newUser As New User(txtUserName.Text, txtPassword.Text)
        If newUser.SaveUser() = 0 Then
            MsgBox("User Not Saved")
        Else
            MsgBox("User Successfully Saved")
        End If

    End Sub

    End Sub


modified on Thursday, January 21, 2010 7:04 AM

QuestionMemory usage Pin
cstrader23220-Jan-10 17:26
cstrader23220-Jan-10 17:26 
AnswerRe: Memory usage Pin
Abhinav S20-Jan-10 17:49
Abhinav S20-Jan-10 17:49 
AnswerRe: Memory usage Pin
Luc Pattyn20-Jan-10 18:08
sitebuilderLuc Pattyn20-Jan-10 18:08 
GeneralRe: Memory usage Pin
cstrader2324-Feb-10 3:51
cstrader2324-Feb-10 3:51 
GeneralRe: Memory usage Pin
Luc Pattyn4-Feb-10 4:09
sitebuilderLuc Pattyn4-Feb-10 4:09 
GeneralRe: Memory usage Pin
cstrader2324-Feb-10 9:48
cstrader2324-Feb-10 9:48 
GeneralRe: Memory usage Pin
Luc Pattyn4-Feb-10 9:58
sitebuilderLuc Pattyn4-Feb-10 9:58 
QuestionCall function in VBA (Access 2007) Pin
misCafe20-Jan-10 17:06
misCafe20-Jan-10 17:06 
AnswerRe: Call function in VBA (Access 2007) Pin
_Damian S_20-Jan-10 17:27
professional_Damian S_20-Jan-10 17:27 
AnswerRe: Call function in VBA (Access 2007) Pin
Steven J Jowett21-Jan-10 10:19
Steven J Jowett21-Jan-10 10:19 
GeneralRe: Call function in VBA (Access 2007) Pin
misCafe21-Jan-10 13:19
misCafe21-Jan-10 13:19 
QuestionExport folder directory listing to Excel with Hyperlinks Pin
cavana120-Jan-10 4:11
cavana120-Jan-10 4:11 
AnswerRe: Export folder directory listing to Excel with Hyperlinks Pin
Steven J Jowett20-Jan-10 7:08
Steven J Jowett20-Jan-10 7:08 
QuestionGetpicture method in ocx Pin
Mohamed Asane19-Jan-10 21:39
Mohamed Asane19-Jan-10 21:39 
AnswerRe: Getpicture method in ocx Pin
Estys20-Jan-10 2:14
Estys20-Jan-10 2:14 
GeneralRe: Getpicture method in ocx Pin
Mohamed Asane20-Jan-10 17:39
Mohamed Asane20-Jan-10 17:39 
GeneralRe: Getpicture method in ocx Pin
Estys21-Jan-10 2:05
Estys21-Jan-10 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.