Re: Newbie with Database Connection Problem
- From: "No_So_Clever" <NOSPAM@xxxxxxxxxx>
- Date: Tue, 25 Oct 2005 09:04:53 +0100
Hi there,
I`ve added the line in and depending on what I select in my Combo Box
(Database 1 or Database 2) it gives me a 0 or a 1. Now tho my App Fails on
Con.Open
with the following Error:
Additional information: No error information available:
DB_SEC_E_AUTH_FAILED(0x80040E4D).
My Code is:
Dim UP As New OleDb.OleDbCommand
Dim Con As New OleDb.OleDbConnection
Dim Read As OleDb.OleDbDataReader
Dim Plus As Integer
Public CurrentForm As System.Windows.Forms.Form
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Connection string
Con.ConnectionString = Connection.String
'Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=J:\Database\MasterDB.mdb"
UP.Connection = Con
UP.CommandType = CommandType.Text
UP.CommandText = "Select * From Passwords Where Users_Name=? and
Users_Password=?"
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
Connection.setString(Me.cboSelectDB.SelectedIndex)
If txtUserName.Text.Trim = "" Then
MessageBox.Show("Please fill your User Name !", "Password",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtUserName.Focus()
Exit Sub
End If
If txtPassword.Text.Trim = "" Then
MessageBox.Show("Please fill your Password !", "Password",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtPassword.Focus()
Exit Sub
End If
'Admin
UP.Parameters.Add("user", Data.OleDb.OleDbType.Variant)
UP.Parameters.Add("password", Data.OleDb.OleDbType.Variant)
UP.Parameters("user").Value = txtUserName.Text
UP.Parameters("password").Value = txtPassword.Text
'Open database connection
Con.Open()
' Read information from database
Read = UP.ExecuteReader
ar()
' Close database connection
Con.Close()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Many Thanks
Si
"W.G. Ryan - MVP" <WilliamRyan@xxxxxxxxxxxxxxxx> wrote in message
news:OI8R8uM2FHA.3332@xxxxxxxxxxxxxxxxxxxxxxx
> Ok, but what value does ind have in this line?
> mLocation = connArray(ind).ToString
> if this is a winforms application, stick this in the line before it:
>
> MessageBox.Show(ind.ToString())
>
> "No_So_Clever" <NOSPAM@xxxxxxxxxx> wrote in message
> news:3rGcnR2uQ9ojj8DeSa8jmw@xxxxxxxxxxxxxx
>> Hi there Thanks again for your help but ....Sorry I don`t understand what
>> you mean:(
>>
>> Like I said im a newbie - would I put:
>>
>> Dim connArray As New ArrayList
>> connArray.Add("J:\Database\MasterDB.mdb")
>> connArray.Add("J:\Database\TestDB.mdb")
>> Try
>> mLocation = connArray(ind).ToString
>> Catch indException As System.Exception
>> Throw indException
>> End Try
>>
>> Cheers
>> NSC
>>
>> "W.G. Ryan - MVP" <WilliamRyan@xxxxxxxxxxxxxxxx> wrote in message
>> news:OLTn7rL2FHA.3864@xxxxxxxxxxxxxxxxxxxxxxx
>>> Put a breakpoint right before the line that references ind and see what
>>> the value is. Or use Debug.WriteLine(ind.ToString()); and see what that
>>> tells you. Based on teh exception I think that may be the problem.
>>> "No_So_Clever" <NOSPAM@xxxxxxxxxx> wrote in message
>>> news:G4ecnf95E4HFksDeSa8jmw@xxxxxxxxxxxxxx
>>>> Hi
>>>>
>>>> ind is the location of my Database.i think,
>>>>
>>>> To be honest im a newbie and i took th code from another prog, to try
>>>> nd use in my app. So im a little unaware and now vey confused.
>>>>
>>>> Many Thanks
>>>> NSC
>>>>
>>>> "W.G. Ryan - MVP" <WilliamRyan@xxxxxxxxxxxxxxxx> wrote in message
>>>> news:e6AScXL2FHA.916@xxxxxxxxxxxxxxxxxxxxxxx
>>>>> What is the value of Ind?
>>>>> "No_So_Clever" <NOSPAM@xxxxxxxxxx> wrote in message
>>>>> news:UXydnSEwI9YXmMDeSa8jmw@xxxxxxxxxxxxxx
>>>>>> Hi,
>>>>>>
>>>>>> Wonder if Somebody could help me? I`ve been searching all over for a
>>>>>> solution but am totally lost.
>>>>>>
>>>>>> I have a Class called Connection as below:
>>>>>>
>>>>>> Public Class Connection
>>>>>> Private Shared mConnectionsstring As String =
>>>>>> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
>>>>>> Private Shared mLocation As String
>>>>>> Private Shared connArray As ArrayList
>>>>>> Public Shared Sub setString(ByVal ind As Integer)
>>>>>> Dim connArray As New ArrayList
>>>>>> connArray.Add("J:\Database\MasterDB.mdb")
>>>>>> connArray.Add("J:\Database\TestDB.mdb")
>>>>>> mLocation = connArray(ind).ToString
>>>>>> End Sub
>>>>>> Public Shared ReadOnly Property [String]() As String
>>>>>> Get
>>>>>> Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mLocation &
>>>>>> ";"
>>>>>> End Get
>>>>>> End Property
>>>>>> End Class
>>>>>>
>>>>>> On my Main Form I have my Database Connection Setup as:
>>>>>>
>>>>>> Dim UP As New OleDb.OleDbCommand()
>>>>>> Dim Con As New OleDb.OleDbConnection()
>>>>>> Connection.setString(Me.cboSelectDB.SelectedIndex)
>>>>>> Con.ConnectionString = Connection.String
>>>>>> UP.Connection = Con
>>>>>> UP.CommandType = CommandType.Text
>>>>>> UP.CommandText = "Select * From Passwords Where Users_Name=? and
>>>>>> Users_Password=?"
>>>>>> End Sub
>>>>>>
>>>>>> But when I run my App it Errors on line "mLocation =
>>>>>> connArray(ind).ToString" with the following error: "Additional
>>>>>> information: Index was out of range. Must be non-negative and less
>>>>>> than the size of the collection"
>>>>>>
>>>>>> Anybody point me in the right direction?
>>>>>> Many Thanks in Advance
>>>>>> Regards
>>>>>> Not_So_Clever
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
.
- Follow-Ups:
- Re: Newbie with Database Connection Problem
- From: W.G. Ryan - MVP
- Re: Newbie with Database Connection Problem
- References:
- Newbie with Database Connection Problem
- From: No_So_Clever
- Re: Newbie with Database Connection Problem
- From: W.G. Ryan - MVP
- Re: Newbie with Database Connection Problem
- From: No_So_Clever
- Re: Newbie with Database Connection Problem
- From: W.G. Ryan - MVP
- Re: Newbie with Database Connection Problem
- From: No_So_Clever
- Re: Newbie with Database Connection Problem
- From: W.G. Ryan - MVP
- Newbie with Database Connection Problem
- Prev by Date: Re: how to know the table is exist in the database
- Next by Date: Re: how to know the table is exist in the database
- Previous by thread: Re: Newbie with Database Connection Problem
- Next by thread: Re: Newbie with Database Connection Problem
- Index(es):