By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

When i connect my vb.net with sql database i got this msg

P: 2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim connection As New SqlClient.SqlConnection
  3.         Dim command As New SqlClient.SqlCommand
  4.         Dim adaptor As New SqlClient.SqlDataAdapter
  5.         Dim dataset As New DataSet
  6.         connection.ConnectionString = ("Data Source=.\SQLEXPRESS;CYRUS-PC\SQLEXPRESS\Databases\sample\Tables\dbo.Login=|DataDirectory|\DataBase.mdf;Integrated Security=True;User Instance=True")
  7.         command.CommandText = "SELECT * FROM Login WHERE UserName='" & TextBox1.Text & "' AND Passwords='" & TextBox2.Text & "';"
  8.         connection.Open()
  9.         command.Connection = connection
  10.         adaptor.selectCommand = command
  11.         adaptor.Fill(dataset, "0")
  12.         Dim count = dataset.Tables(0).Rows.Count
  13.         If count > 0 Then
  14.             MsgBox("Login Successfull", MsgBoxStyle.Information, "Login Passed")
  15.         Else
  16.             MsgBox("Invalid Account", MsgBoxStyle.Critical, "Login Failed")
  17.             txtUsernameBox1.Clear()
  18.             txtpassword.Clear()
  19.         End If
  20.     End Sub
  21.  
Sep 26 '14 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
What message do you get?
Oct 16 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.