Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2005, 09:15 AM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default OleDbCommand and OleDbDataReader Question

I placed my page at webmatrixhosting and found that it can't run (it should run well as no problem with my own pc)

So could anyone tell me what wrong with the line of
myReader = myCommand.ExecuteReader()
note: myRead is a OleDbDataReader

Code:
<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.oledb" %>
<html>
<head>
</head>
<body>
    <%
        Dim mySelectQuery As String = "SELECT item_id,item_name FROM item"
            Dim myConnection As New OleDbConnection(application("cnStr"))
        Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
        myConnection.Open()
        Dim myReader As OleDbDataReader
        myReader = myCommand.ExecuteReader()
        ' Always call Read before accessing data.
        While myReader.Read()
            response.write(myReader.GetInt32(0).ToString() + ", " _
            + myReader.GetString(1) + "<BR>")
        End While
        ' always call Close when done reading.
        myReader.Close()
        ' Close the connection when done with it.
        myConnection.Close()
    %>
</body>
</html>
__________________
For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text
 
Old April 13th, 2005, 08:07 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Are you getting an error message? Can we see it? Nothing looks obviously wrong with what you have.

-Peter
 
Old April 13th, 2005, 08:58 PM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 Are you getting an error message? Can we see it? Nothing looks obviously wrong with what you have.

-Peter
here is the error showed by that hosing
Code:
Selected collating sequence not supported by the operating system. 
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: Selected collating sequence not supported by the operating system.

Source Error: 


Line 19:                 cmd.parameters("@login_id").value=txtid.text
Line 20:     
Line 21:                 dim dr as OleDbDataReader=cmd.ExecuteReader(CommandBehavior.CloseConnection)
Line 22:                 'Check password
Line 23:                 if dr.read() and dr.getString(0)=txtpassword.text
 
Old April 13th, 2005, 09:30 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This sounds like some kind of database/os configuration problem.
 
Old April 14th, 2005, 09:04 AM
Authorized User
 
Join Date: Nov 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 This sounds like some kind of database/os configuration problem.
but for another code its work!
here is the working code:

I don't know why that code work, while my code being punished by the server
Code:
<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Oledb" %>
<script runat="server">

    Sub Page_Load()
       Dim strConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;"
         strConnection &= "Data Source=" & Server.MapPath("Northwind.mdb")
         data_src.text = strConnection
         application("strConnection")=strConnection
       Dim strSQL as string = "select FirstName, LastName from Employees"
       Dim strResultsHolder as string

       Dim objConnection as New OledbConnection(application("STRConnection"))
       Dim objCommand as New OledbCommand(strSQL, objConnection)
       Dim objDataReader as OledbDataReader

       try
         objConnection.Open()
         con_open.text="Connection opened successfully.<br />"
       objDataReader = objCommand.ExecuteREader()

       Do While objDataReader.Read()=True
         strResultsHolder +=objDataREader("FirstName")
         strResultsHolder +="&nbsp;"
         strResultsHolder +=objDataREader("LastName")
         strResultsHolder +="<br>"
       Loop

       objDataReader.Close()
         objConnection.Close()
         con_close.text="Connection closed.<br>"
       divListEmployees.innerHTML = strResultsHolder
       catch e as Exception
         con_open.text="Connection failed to open successfully.<br>"
         con_close.text=e.ToString()
       end try
    end Sub

</script>
<html>
<head>
</head>
<body>
    <h4>Reading data from the connection <asp:Label id="data_src" runat="server"></asp:Label>with
        the DataReader object. 
    </h4>
    <asp:Label id="con_open" runat="server"></asp:Label>
    <br />
    <div id="divListEmployees" runat="server">list will go here 
    </div>
    <asp:Label id="con_close" runat="server"></asp:Label>
    <br />
</body>
</html>
For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text





Similar Threads
Thread Thread Starter Forum Replies Last Post
OleDbCommand Problems FalseParadigm VB Databases Basics 8 April 10th, 2007 03:01 PM
DALBase? and Oledbdatareader nikosnyc VB Databases Basics 2 May 2nd, 2006 09:08 AM
What is OleDBDataReader.GetValue() means? Dragonist ADO.NET 2 July 5th, 2004 07:24 PM
OleDbCommand.ExecuteNonQuery(); kaz VS.NET 2002/2003 1 December 7th, 2003 04:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.