simple question

  • Thread starter Web Search Store
  • Start date
W

Web Search Store

Hello,

I'm finally trying to use asp.net


I would appreciate any code sample on how to translate the following code
that opens an access database:

dim mydsn
dim conntemp
dim sqlstmt
mydsn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=c:\myaccessdb.mdb"
set conntemp=server.createobject("adodb.connection")
conntemp.open mydsn
sqlstmt = "Select * from item_table order by item_matching_score DESC"
Set RS = conntemp.Execute(sqlstmt)
if not RS.bof and not RS.eof then
response.write "<br>record number=" & cstr(RS("item_number"))
end if

Or tell me the best place to look for this.

Thank you very much.

Scott
 
S

Scott M.

Using con As New
OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=c:\myaccessdb.mdb")
Dim cmd As New OleDb.OleDBCommand("Select * from item_table order by
item_matching_score DESC", con)

Try
con.Open
Dim dr As OleDb.OleDbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim i As Integer = 1
Do While dr.Read()
Response.Write("<br>record number=" & i)
i +=1
Loop
Catch ex As OleDbException
'Handle exceptions from the database here

Catch ex As Exception
'Handle exceptions from .NET here

Finally
dr.Close()
dr.Dispose()
cmd.Dispose()
End Try

End Using
 
W

Web Search Store

Thank you very much!

I'll give it a try.

Scott
Scott M. said:
Using con As New
OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=c:\myaccessdb.mdb")
Dim cmd As New OleDb.OleDBCommand("Select * from item_table order by
item_matching_score DESC", con)

Try
con.Open
Dim dr As OleDb.OleDbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim i As Integer = 1
Do While dr.Read()
Response.Write("<br>record number=" & i)
i +=1
Loop
Catch ex As OleDbException
'Handle exceptions from the database here

Catch ex As Exception
'Handle exceptions from .NET here

Finally
dr.Close()
dr.Dispose()
cmd.Dispose()
End Try

End Using
 
W

Web Search Store

When I used the code pasted here, I got the error pasted below it:


Any help appreciated.

Scott
<html>


<%


Using con As New
system.data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE='e:\websearchstore_server\data\database_directory.mdb'")
Dim cmd As New system.data.OleDb.OleDBCommand("Select * from
www_item_table ", con)
con.Open
Dim dr As system.data.OleDb.OleDbDataReader =
cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)

Try

Dim i As Integer = 1
Do While dr.Read()
Response.Write("<br>record number=" & i)
i +=1
Loop
Catch ex As system.data.oledb.OleDbException
'Handle exceptions from the database here

Catch ex As Exception
'Handle exceptions from .NET here

Finally
dr.Close()
dr.Dispose()
cmd.Dispose()
End Try

End Using


%>
</html>


Could not find installable ISAM.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Could not find
installable ISAM.

Source Error:

Line 7: Using con As New
system.data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE='e:\websearchstore_server\data\database_directory.mdb'")
Line 8: Dim cmd As New system.data.OleDb.OleDBCommand("Select * from
www_item_table ", con)
Line 9: con.Open
Line 10: Dim dr As system.data.OleDb.OleDbDataReader =
cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
Line 11:
 
S

Scott M.

That usually means that you haven't specified the correction database
provider or don't have the correct provider.

The connection string I provided is correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top