Hi, I seem to be getting this error and I have no idea how to fix it, everything is correct with passwords etc (the *'s are for security only) here is the code for you guys to have a look at.
conn.Open() - is where the error is hapeening, this is my first time working with databases, so I am really pleased to come this far but I am baffled
Many Thanks!
conn.Open() - is where the error is hapeening, this is my first time working with databases, so I am really pleased to come this far but I am baffled
Many Thanks!
VB.NET:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim anIntArray As Integer() = New Integer() {}
Dim mypath = Application.StartupPath & "C:\Temp\myDB.accdb"
Dim mypassword = "********"
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mypath & ";Jet OLEDB:Database Password=" & mypassword)
Dim cmd As OleDbCommand
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Network.IsAvailable() Then
My.Computer.Network.DownloadFile("http://www.runeexile.info/123abcxxxxk5/myDB.accdb", "C:\Temp\myDB.accdb", "****", "******", True, 10000, True, FileIO.UICancelOption.DoNothing)
Else
MsgBox("An Internet connection could not be established, please check your network settings.")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sql = "SELECT UserID ,PassID FROM MYTAB WHERE USERID='" & TextBox1.Text & "' AND PASSID='" & TextBox2.Text & "'"
cmd = New OleDbCommand(sql, conn)
[B][SIZE="3"]conn.Open()[/SIZE][/B]
Dim dr As OleDbDataReader = cmd.ExecuteReader
Try
If dr.Read = False Then
MessageBox.Show("Authentication failed...")
Else
MessageBox.Show("Login successfully...")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
End Class