February 2008 - Posts
I posted my problem on Oracle's OTN Discussion Forum (http://forums.oracle.com/forums/thread.jspa?messageID=2366331�) and got two great answers.
It turns out that I was using Microsoft's Oracle provider, not Oracle's. Make sure you install Oracle's software and take care to select the right provider when creating a connection. Here's an example connection string for ASP.NET 3.5:
<connectionStrings>
<add name="ConnectionString1" connectionString="Data Source=192.168.1.104/orcl;Persist Security Info=True;User ID=system;Password=xxxpwd!!;"
providerName="Oracle.DataAccess.Client" />
</connectionStrings>
Here's a useful reply from Alex Keh on their forums:
"I would recommend using Oracle Developer Tools (ODT) for VS and ODP.NET since these products are much better integrated with .NET and Oracle.
ODP.NET uses Oracle.DataAccess.Client namespace. System.Data.OracleClient belongs to the MS provider for Oracle, which Mark pointed out. If you drag and drop DB objects using ODT, it will generate ODP.NET code for you (and give you more data source wizard options as well).
You can download the latest 11g version of ODP.NET and ODT here:
http://www.oracle.com/technology/software/tech/windows/odpnet/index.html
These support .NET 3.5 and VS 2008. "
Update: Fixed as described here: http://weblogs.asp.net/kencox/archive/2008/02/25/fixed-oracle-11g-and-sqldatasource-the-ugly-ora-01036-illegal-variable-name-number-issue.aspx
----
I've created a short video to explain my problem with Oracle and SqlDataSource. If you'd rather watch than read, go see the video.
I'm trying to do some extremely simple drag and drop development in Visual Web Developer 2008 with the Oracle 11g database and ODP.NET. According to Oracle, "The data provider can be used with the latest .NET Framework 3.5 version. "
The SELECT statement works fine, but any attempt to use UPDATE via the SQLDataSource UpdateCommand nets me the infamous 'ORA-01036: illegal variable name/number' error.
I wouldn't mind using one of my MSDN Support Incidents to have Microsoft take a look at this issue, but I'm not sure the problem is Microsoft's. It seems like Oracle is doing a poor job in its Visual Studio integration.
Question: Has anyone successfully used an UpdateCommand statement in SQLDataSource against Oracle 11g? If so, let me know!
Below, you see the entire code as generated in Visual Web Developer 2008. To see it in action, check the video.
Ken
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display.">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ACCOUNTID" HeaderText="ACCOUNTID"
SortExpression="ACCOUNTID" />
<asp:BoundField DataField="ACCOUNTNAME" HeaderText="ACCOUNTNAME"
SortExpression="ACCOUNTNAME" />
<asp:BoundField DataField="ACCOUNTLOCATION" HeaderText="ACCOUNTLOCATION"
SortExpression="ACCOUNTLOCATION" />
<asp:BoundField DataField="ACCOUNTPHONE" HeaderText="ACCOUNTPHONE"
SortExpression="ACCOUNTPHONE" />
<asp:BoundField DataField="ACCOUNTCONTACT" HeaderText="ACCOUNTCONTACT"
SortExpression="ACCOUNTCONTACT" />
<asp:BoundField DataField="ACCOUNTWEBSITE" HeaderText="ACCOUNTWEBSITE"
SortExpression="ACCOUNTWEBSITE" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString1.ProviderName %>"
SelectCommand="SELECT "ACCOUNTID", "ACCOUNTNAME", "ACCOUNTLOCATION", "ACCOUNTPHONE", "ACCOUNTCONTACT", "ACCOUNTWEBSITE" FROM "ACCOUNTS""
UpdateCommand="UPDATE ACCOUNTS SET ACCOUNTLOCATION = 'This Place' WHERE (ACCOUNTID = 4)">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
//////////
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Aspose is one of the major component vendors, and famous for creating controls that read and write files in the formats of the Microsoft Office suite. I downloaded the Aspose.Total bundle today and noticed something odd. I didn't recognize the names of the individual products. I recalled mentioning Aspose products in an article a few years ago with names like Aspose.Word, Aspose.Excel and so on. A quick search turned up a review of Aspose.Excel by my MVP colleague Steve C. Orr.
Gosh, I've been out of the loop! The products in the suite now carry the names Aspose.Cells (Excel), Aspose.Slides (PowerPoint), Aspose.Tasks (Project), and Aspose.Words (Word). When did this happen? I found a reference on the Aspose site to updating references in Visual Studio dating back over two years ago.
I have no knowledge of what went on, but my first suspects would be Microsoft's ever-friendly "Internet investigators". These are the legal-beagle sharp-shooters who once went after an MVP because he dared to update and distribute Microsoft's browscap.ini file (used to detect browsers in ASP Classic).
What's in a name? that which we call Aspose
By any other name would sell a suite.
(Sorry about the preceding. I just couldn't resist. Anyway, Aspose makes fine .NET components.)
At first blush, it may seem strange for me to review a "competing" ASP.NET 3.5 book. However, Stephen Walther's ASP.NET 3.5 Unleashed doesn't target the same audience as ASP.NET 3.5 For Dummies. Mine is unabashedly a beginner's book. ASP.NET Unleashed is a comprehensive title for intermediate to advanced programmers and definitely hits its mark.
At over 1800 pages, this is definitely not "light" reading. It is, however, packed with most everything a professional ASP.NET developer needs to know to work in ASP.NET 3.5.
I was struck early on with Walther's assertion at the opening of Chapter 31 (Using Server-Side ASP.NET AJAX) that the future is AJAX:
"Microsoft ASP.NET is a dying technology. It received its death blow on February 18, 2005 when Jess James Garrett published his article 'Ajax: A New Approach to Web Applications.' All that is left is the long, slow goodbye."
The author encourages readers to "leave the safety of the server side and enter the wilds of the client side." To that end, Walther does an excellent job of explaining the use of the UpdatePanel, Timer, and UpdateProgress controls that are built into ASP.NET 3.5.
The subsequent chapter, Using the ASP.NET AJAX Control Toolkit, gives a solid overview of the toolkit's suite. It then shows how to use the AutoComplete, DragPanel, FilteredTextBox, MaskedEdit, Animation, and UpdatePanelAnimation controls. As always, there are many code listings (in C# in this edition). Chapter 33 digs even deeper into AJAX to program client-side applications against the Microsoft AJAX Library. If you're ramping up to build on the client, the book's AJAX content is very valuable.
The book is also solid on LINQ, the popular addition to ASP.NET 3.5. Chapter 18 goes through the concepts of LINQ to SQL entities, automatic properties, initializers, type inference, anonymous types, and lambda expressions. You learn how to perform standard database commands using LINQ to SQL and debug your queries.
This is a programmer's book, for sure. Where my book caters to beginners by using the IDE's graphical tools, Walther writes and explains lots of code. Don't look for numbered steps telling you where to click in Visual Studio 2008. The book focuses more on ASP.NET code than how to get the IDE to write it. This makes sense for the intermediate and advanced audience. Interesting to note, however that ASP.NET 3.5 Unleashed uses the single .aspx page model very effectively that I recommend for beginners. The book includes a CD with tons of valuable samples in C# and VB.
I have only two minor issues with this book: Firstly, the screenshots take up an excessive amount of space on the pages for very little value. For example, at page 448, Figure 10.6 takes up half a page to display a list control, a label, and a button scrunched into the top left corner of a browser page. I wish Sams would revise its template standard to do away with full page screenshots and focus on what's important. Secondly, the book is too heavy to rest comfortably on my stomach for bedtime reading. Buy a tray for increased comfort! <grin>
In summary, if you're an ASP.NET beginner, start with my book and graduate to ASP.NET Unleashed as you expand your confidence and capabilities. If you're already working comfortably in .NET, you only need this book and the MSDN reference documentation. Buy it.
I'm implementing ASP.NET roles in a site and using the securityTrimmingEnabled feature so people don't see menu items for pages they're not authorized to visit.
Once I got the roles and restrictions enabled, the entire menu disappeared as if the role had no authorization to see any items. That's security trimming gone wild!
It turns out that this is an issue when you're using a horizontal ASP.NET menu. You usually hide the root node of the sitemap file when using a horizontal menu because a top row with one lonely root item doesn't make sense. (The SiteMapDataSource ShowStartingNode property is set to False.)
The fix was to make sure that every role had access to the (unused) dummy siteMapNode at the root by including roles="*" in web.sitemap shown below:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap enableLocalization="true"
xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" roles="*" description="">
<siteMapNode url="~/default.aspx" resourceKey="siteMapHome"
title="Home" roles="admin,account" description="" />
<!-----More nodes-->
Sheesh! Why do I lose time on these silly things? Is nothing ever easy?
I hope you'll forgive a bit of self-promotion. I haven't blogged much about my book ASP.NET 3.5 For Dummies because it's a beginner's book. Most readers here are ASP.NET experts who could (and do) write advanced books and articles on ASP.NET.
That said, I finally have a bound, hardcopy edition on my lap and wanted to talk about it. It feels good to see the tangible result of months of work. I did my best to write a hands-on, tasked-based book that serves as a useful introduction to a very sophisticated technology. As I say in the book, we're all beginners at some point. Even the lifeguard started in the shallow end of the pool.
The nice thing about writing a Dummies book is the chance to include some humour. For example, I often poke fun at geeks and their strange, bloated words like "disambiguating".
It says a lot that the Dummies concept has done so well in the marketplace. Are people so desperate for clear, readable information on complex subjects that they're willing to buy a book that labels them a dummy? Maybe book stores should sell these titles in a brown paper wrapper!
Let's say you've just started a new job and feel insecure about the technology. Perhaps you'd buy a Dummies book to increase your comfort level and get up to speed. You devour the contents in the privacy of your home, sure. But would you leave the book open on your desk at work? Would you worry about sending an unsettling message to your new boss and colleagues?
Then again, maybe buying a Dummies book makes a bold statement that the purchaser has a life and doesn't intend to spend all his/her waking hours accomplishing a few technical tasks?
If you want to know more about the book, check out my support site at http://www.kencox.ca/.
Interesting interview with Scott during his recent trip. He discusses MVC around minute 14:30.
http://www.microsoft.com/japan/msdn/events/vs2008/scott/interview.html
More Posts