Connection string for mysql database and how to write stored procedure in mysql database and use it
To write a stored procedure for login page in MySql database and use that in windows login form.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Rohatash KumarRank #12 · 57.7K reputationPosted Jul 5, 2011, 9:26 PM EDT
creating a table in SQL server database which has the username, password and email fields. Table looks like this.
create table registrationtab
(
Username varchar(100),
Email varchar(100),
Password varchar(20)
)
Step-2
Create stored procedure
Now Creating stored procedure for login. That means values will be match in table using stored procedure. Stored procedure looks like that for it.
create PROCEDURE CheckUser
(
@username as varchar(50),
@password as varchar(50)
)
AS
SELECT* FROM registrationtab WHERE username=@username AND password=@password
Now creating a window form with the username and password field which are defined in the table. And write following code in login button event.
Dim strcon As String = "Data Source=.;uid=sa;pwd=Password$2;database=master"
Dim con As New SqlConnection(strcon)
Dim com As New SqlCommand("CheckUser", con)
com.CommandType = CommandType.StoredProcedure
Dim p1 As New SqlParameter("username", TextBoxusername.Text)
Dim p2 As New SqlParameter("password", TextBoxpassword.Text)
com.Parameters.Add(p1)
com.Parameters.Add(p2)
con.Open()
Dim rd As SqlDataReader = com.ExecuteReader()
If rd.HasRows Then
rd.Read()
Labelinfo.Text = "Login successful."
Else
Labelinfo.Text = "Invalid username or password."
End If
GAUTAM RAPARTHI13 reputationPosted Jul 6, 2011, 4:13 AM EDT
When i am trying to execute the procedue in MySql ,its getting error.So,please provide the solution of how to do it by using MySql database as soon as possible.