|
What is your connection string? I didn't see anything about that in your sample code...
|
|
|
|
|
Imports MySql.Data.MySqlClient ' this is to import MySQL.NET
Public Class Form1
Dim connString As String = "server=seerver;" _
& "user id=username;" _
& "password=xxxxxxx;" _
& "database=databasename"
Dim conn As New MySqlConnection(connString)
Dim da As MySqlDataAdapter
Dim dst As New DataSet
Dim State As StateEnum
Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
conn.Close()
conn.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Dim myCommand As New MySqlCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
conn.Open()
da = New MySqlDataAdapter("SELECT * FROM tblSysLogin WHERE username='" & TextBox1.Text.ToString & "' and password='" & TextBox2.Text & "'", conn)
myCommand.ExecuteScalar()
If myCommand.ExecuteScalar > 0 Then
MsgBox("success")
Else
MsgBox("error")
conn.Close()
End If
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
End Sub
End Class
this is the complete code i have in the login form
|
|
|
|
|
LegionFX wrote: Dim connString As String = "server=seerver;" _
& "user id=username;" _
& "password=xxxxxxx;" _
& "database=databasename"
Make sure the MySQL service is running on the machine named seerver, or you could try the ip address of seerver. I think you may need to specify the port as well, which is default to 3306...
|
|
|
|
|
The server is running fine. the connection is fine, the only problem i have in the code is finding out how to check if the username and password exist in the database table .
ive searched on google but only find integrated security and msaccess examples (in vb.net).
Cheers...
|
|
|
|
|
LegionFX wrote: da = New MySqlDataAdapter("SELECT * FROM tblSysLogin WHERE username='" & TextBox1.Text.ToString & "' and password='" & TextBox2.Text & "'", conn)
myCommand.ExecuteScalar()
I don't see anything tying da to myCommand . That might be the problem. Also, the query is subjected to injection attacks, so I'd be careful with that. One great article on this site to check out is SQL Injection Attacks and Some Tips How to Prevent Them[^]...
|
|
|
|
|
there is no attachment between da and myCommand,
if you are trying to get the data,
use mysqldatareader with mysqlcommand.
dim dr as mysqldatareader
dr = cmd.executeQuery()
if dr.read() then
msgbox "success"
else
msgbox "incorrect login"
end if
or if you want to use mySQLDataAdapter then use it with mysqldataset
Vilsad P P
MCTS (Windows Applications) .Net 2.0
|
|
|
|
|
.... nope... i dont want to get the data, i just want to read it to check if certain data is present in the database, and give a true or false result (user exists or not in the database)
your code help a bit but whats the declaration for the CMD.executeQuery.
Cheers and thanks
|
|
|
|
|
case closed, finaly its done.
~
Dim sSQL As String
Dim conn As New MySqlConnection("server=xxxxxx;" _
& "user id=xxxxxxx;" _
& "password=xxxxxxxx;" _
& "database=xxxxxxxx")
Dim cmd As MySqlCommand
Dim drData As MySqlDataReader
Try
conn.Open()
sSQL = ("SELECT * FROM tblSysLogin WHERE username='" & TextBox1.Text.ToString & "' and password='" & TextBox2.Text & "'")
cmd = New MySqlCommand(sSQL, conn)
drData = cmd.ExecuteReader()
If drData.Read() Then
MsgBox("success")
Else
MsgBox("incorrect login")
End If
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
so simple and so complicated.... lol thanks for all you help guys. Cheers
|
|
|
|
|
LegionFX wrote: thanks for all you help guys
Glad you got it working
|
|
|
|
|
glad you got it working
cheers
Vilsad P P
MCTS (Windows Applications) .Net 2.0
|
|
|
|
|
please i want help from any body here
i want to take mcpd exams
for that i want help from any body here have(test king exams (70-536)
-(70-526) for visual basic2005
any body help me
that first time i enter that site
and i hope the help me
and promise any body here to help all after i finish
i wait in my email sadagc2002@yahoo.com
good times with best site
by
saad badr
|
|
|
|
|
Help with what? Whats on the exams? How to register for them? ...
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
thanks for respond
iam searching about the testking and questions
iwant to training on exam before enter
iam searching about e xam but a not found yet
thanks
saad badr
|
|
|
|
|
There are free ones out there, but you get what you pay for. They suck and they don't give you the same experience your going to get in the testing lab. They simulate what topics are going to be covered on the exam, but they have no idea exactly what questions you're going to see.
The best way to pass is to go into the books and practice the techniques, not the tests...
|
|
|
|
|
This is why exams are a joke. People cram for them on the web, know nothing and still pass.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am using a DGV to display data from a DataTable but I've been unable to figure out how to prevent the user from clicking on a cell and selecting it. I'd use DataGridView.Enabled = False if it also didn't prevent the use of the scroll bar.
I also checked out the DataGridView.SetStyle(Selectable, False) member but that is protected so I can't touch it. Does anyone have any suggestions?
I've disabled all editing abilities (adding, deleting, reordering, etc) for it. Setting DataGridView.ReadOnly = true also doesn't work for me.
---- UPDATE:
This problem can be solved with
Private Sub DataGridView3_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView3.SelectionChanged
DataGridView3.CurrentCell.Selected = False
End Sub
-----
Gr,
Mightor
A paralytic chicken ran away with my sig.
-- modified at 15:03 Saturday 5th May, 2007
|
|
|
|
|
hi,
Can any one help with creating a splash screen for an vb.net 2005 application which after a specified interval diappears and the mdiparent form in shown.
If someone help me it would be great help for me.
Thanks
|
|
|
|
|
You'll need to create a form to act as your splash screen. Once you've done that goto Project > Properties. Make sure the Application tab is selected. At the bottom there should be a combobox which is labeled 'Splash Screen'. Just select the form you'd like to use. That's it! If you'd like to adjust the minimum time it displays (I believe the default is 2 seconds) you can set 'My.Application.MinimumSplashScreenDisplayTime' in the new event of your form.
|
|
|
|
|
VS.NET 2005 (not the Express Editions) already comes with a SplashScreen template form. All you have to do is right-click your project in the Solution Explorer, click Add -> New Item..., then double-click the SplashScreen form. Give the form a name, and after it's added to your project, right click the form in the Solution Explorer and click View Code. The instructions for modifying the form are in the code comments.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
It isn't that hard to create a splashscreen from scratch, though.
Dave Kreskowiak wrote: VS.NET 2005 (not the Express Editions) already comes with a SplashScreen template form
Is there anyway to get the splashscreen template for the Express Editions?
|
|
|
|
|
Paul Conrad wrote: It isn't that hard to create a splashscreen from scratch, though.
No, it isn't, for us anyway. For someone who doesn't understand that the startup form also contains the app's message pump, it's a bit confusing.
Paul Conrad wrote: Is there anyway to get the splashscreen template for the Express Editions?
it's not downloadable from anywhere. You'd have to lift a copy of the template files from a higher edition of VS.NET.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Dave Kreskowiak wrote: it's not downloadable from anywhere. You'd have to lift a copy of the template files from a higher edition of VS.NET.
After a bit of googling, that is the conclusion I pretty much came to
Dave Kreskowiak wrote: For someone who doesn't understand that the startup form also contains the app's message pump, it's a bit confusing.
Yep, but it would be a bad little learning exercise either
|
|
|
|
|
Hi,
You can try OPACITY property of your form it might help u.
Put this code in a loop:-
Opacity = i/100.0;// decrease opacity
Thread.Sleep(30);
Regards,
Sumit
|
|
|
|
|
vb.net
i have a form, which is mdi-container. how do i close all open forms in this container-form?
|
|
|
|
|
may be i didnt get your problem exactly...
u want to close all the opend mdi child forms
jst in close button click event write application.exit.
it will close all the opened ald hidden forms....
|
|
|
|