|
|
 |
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9  | This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

November 18th, 2008, 11:09 PM
|
|
Registered User
|
|
Join Date: Nov 2008
Location: Pawleys Island, SC, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Something Fundamental
I am having a very frustrating time trying to use Professional ASP.NET 2.0 Every time I try to run code I get a fundamental error message. I open the downloaded code as a text file; save it as an ASPX file into an ASP.Net website that I created with Visual Web Developer 2005 and then open the code file. I then click on debug and select run without debugging and get very basic error messages. Can anyone tell me what I am doing wrong?
For example, doing this with the code for listing 12-1, I get the following error message (Note Line 16 is all on one line in the file):
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 14:
Line 15: MyConnection = New SqlConnection()
Line 16: MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("DSN_Northw ind").ConnectionString
Line 17:
Line 18:
Source File: D:\websites\pbocchurch\WebSite1\12-01.aspx Line: 16
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._12_01_aspx.Page_Load(Object sender, EventArgs e) in D:\websites\pbocchurch\WebSite1\12-01.aspx:16
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
|

November 19th, 2008, 12:58 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
|
|
Well, if I were GUESSING, I'd say that there is *NO* ConnectionStringSettings with the name "DSN_Northwind" in that collection.
Have you debugged? Have you looked inside ConfigurationManager to see what ConnectionStrings it is holding??
If worst comes to worst, you could check to see just what is in there with code something like the snippet shown here:
http://msdn.microsoft.com/en-us/libr...onmanager.aspx
|

November 19th, 2008, 10:49 PM
|
|
Registered User
|
|
Join Date: Nov 2008
Location: Pawleys Island, SC, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the response. I have this connection string in my web.config file
<connectionStrings>
<add name="committeesConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=D:\websites\pbocchurch\WebSite1\committees. mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
And am getting the following error:
Keyword not supported: 'provider'.
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.ArgumentException: Keyword not supported: 'provider'.
Source Error:
Line 14:
Line 15: MyConnection = New SqlConnection()
Line 16: MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("committees ConnectionString").ConnectionString
Line 17:
Line 18:
|

November 19th, 2008, 11:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
|
|
You are ALREADY specifying the provider via the PROVIDERNAME= attribute. So I'd bet that the PROVIDER= is unnecessary and, of course, not allowed.
Have never used this, but give it a try:
Code:
<connectionStrings>
<add name="committeesConnectionString"
connectionString="Data Source=D:\websites\pbocchurch\WebSite1\committees.mdb"
providerName="System.Data.OleDb"
/>
</connectionStrings>
|

November 23rd, 2008, 10:46 PM
|
|
Registered User
|
|
Join Date: Nov 2008
Location: Pawleys Island, SC, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well now I have a connection string and connection, I think. I am trying to verify by writing the content of the "major" column in the "major" table in the committees.mdb database. (Yes the field and table have the same name.) When I run this code I get a blank browser window. Can you please take a look? Where I want to get to is be able to update the fields in one table's particular record with specific fields from a record selected from a second table. But first I have to connect! Here is my code:
<%@ Page Language=" VB" AutoEventWireup="false" CodeFile="connect.aspx. vb" Inherits="connect" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language=" VB" runat="server">
sub Page_Load(sender as Object, e as EventArgs)
'Create a connection string
Dim connString as String
connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & _
"committees.mdb;"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL As String = "SELECT * FROM major"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL, objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConn ection)
Dim asd As String
While objDataReader.Read()
asd = objDataReader("major")
Response.Write(asd)
End While
'Close the datareader/db connection
objDataReader.Close()
End Sub
</script>
I have also tried this with the following line
asd = objDataReader(1)
|

November 24th, 2008, 11:41 AM
|
|
Registered User
|
|
Join Date: Nov 2008
Location: Pawleys Island, SC, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well, I connected! FInally. I had to change the connection string from
connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & _
"committees.mdb;"
to
Dim cn As New Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet .OLEDB.4.0;DATA SOURCE=" & _
"D:\websites\pbocchurch\church\aspx\committees.mdb ;")
I am using IIS on my Windows XP Pro PC to test my pages. When I used ASP, just committees.mdb worked, since the database is in the same folder as the asp file (or in this case aspx). NOw I get "Could not find file 'C:\WINDOWS\system32\committees.mdb'" Do I have to do something in IIS? The folder is set to run asp.net
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |