Imports System.Data.SQLClient
Partial Class Form1
Dim myconn As SqlConnection
Private Sub Button1_Click
Dim myconn As New SqlConnection
myconn = New SqlConnection("Provider=SQLNCLI;Persist Security Info=False;User ID=usr;Password=psw;attachdbfile=indirizzo;data source=www.dominio.it")
Try
myconn.Open()
Catch En As Exception
MsgBox(En.ToString)
Exit Sub
End Try
Dim MyOleCmd As SqlCommand
Dim MyOleRead As SqlDataReader
Dim strSQL As String
strSQL = "SELECT * FROM tbUtenti WHERE dsUtente = '" & Trim(user.Text) & "' AND dsPassword = '" & Trim(pass.Text) & "'"
MyOleCmd = New SqlCommand(strSQL, myconn)
MyOleRead = MyOleCmd.ExecuteReader()
If MyOleRead.HasRows Then
Do While MyOleRead.Read
Try
Catch Ex As IndexOutOfRangeException
MsgBox("ciao")
End Try
Loop
Else
MsgBox("Username o Password Errate")
MyOleRead.Close()
If myconn.State <> Data.ConnectionState.Closed Then
myconn.Close()
End If
user.Text = ""
pass.Text = ""
Exit Sub
End If
MyOleRead.Close()
If myconn.State <> Data.ConnectionState.Closed Then
myconn.Close()
End If
priva utilizzavo oledbconnection ....
ora la classe sql client
ma mi da erorre sulla stringa di connessione
nome provider non supportato