I'm trying to do several things here, and not having much luck with any of them...! Any help would be greatly appreciated. I need to first connect to a database (trying Oracle now, as that is my end goal, but couldn't even get a local Access Database to work) and then use values from the database to populate a dropdown list.
Current Oracle string error message is: System.ArgumentException: An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
If I try the Access string, I get: System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file 'C:\test.mdb'. It is already opened exclusively by another user, or you need permission to view its data. (even though I don't have it open, and it's not write- or password-protected)
Also, I've tried to add the System.Data.OracleClient namespace, but it doesn't recognize it. Has anyone run into this before?
TIA,
Lindsay
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Load the values from the database into the drop down list
If Not IsPostBack Then
Dim connectionString As String
'Testing local Access database - also doesn't work
'connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb;"
'Testing Oracle database on another server
connectionString = "server=111.111.111.111:1521;uid=myuser;pwd=mypassword;database=DBNAME;"
Dim myOleConnection As New OleDbConnection(connectionString)
Dim myOleCommand As OleDbCommand
Dim myReader As OleDbDataReader
Dim sqlText As String = "SELECT FIRSTNAME, LASTNAME from USER"
myOleCommand = New OleDbCommand(sqlText, myOleConnection)
myOleCommand = New OleDbCommand(sqlText, myOleConnection)
Dim values As ArrayList = New ArrayList()
Try
myOleConnection.Open()
myReader = myOleCommand.ExecuteReader()
Do While (myReader.Read())
values.Add(myReader("FIRSTNAME"
)
values.Add(myReader("LASTNAME"
)
Loop
ddNameCode.DataSource = values
ddNameCode.DataBind()
Catch x As Exception
txtOpen.Text = "Connection failed to open"
txtClose.Text = x.ToString()
End Try
End If
End Sub
Current Oracle string error message is: System.ArgumentException: An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
If I try the Access string, I get: System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file 'C:\test.mdb'. It is already opened exclusively by another user, or you need permission to view its data. (even though I don't have it open, and it's not write- or password-protected)
Also, I've tried to add the System.Data.OracleClient namespace, but it doesn't recognize it. Has anyone run into this before?
TIA,
Lindsay
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Load the values from the database into the drop down list
If Not IsPostBack Then
Dim connectionString As String
'Testing local Access database - also doesn't work
'connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb;"
'Testing Oracle database on another server
connectionString = "server=111.111.111.111:1521;uid=myuser;pwd=mypassword;database=DBNAME;"
Dim myOleConnection As New OleDbConnection(connectionString)
Dim myOleCommand As OleDbCommand
Dim myReader As OleDbDataReader
Dim sqlText As String = "SELECT FIRSTNAME, LASTNAME from USER"
myOleCommand = New OleDbCommand(sqlText, myOleConnection)
myOleCommand = New OleDbCommand(sqlText, myOleConnection)
Dim values As ArrayList = New ArrayList()
Try
myOleConnection.Open()
myReader = myOleCommand.ExecuteReader()
Do While (myReader.Read())
values.Add(myReader("FIRSTNAME"
values.Add(myReader("LASTNAME"
Loop
ddNameCode.DataSource = values
ddNameCode.DataBind()
Catch x As Exception
txtOpen.Text = "Connection failed to open"
txtClose.Text = x.ToString()
End Try
End If
End Sub