Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 June 3rd, 2006, 02:50 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default why different syntaxes for 'Command'?

Hi,

I saw three different syntaxes in command lines:
UpdateCommand="UPDATE [mytable] SET [name] = @name ...
UpdateCommand="Update `mytable` set `name`=? ...
UpdateCommand="UPDATE [mytable] SET [name] = ? ...

Does the three do the same?
Why those differences?
Thanks


 
Old June 3rd, 2006, 02:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi hertendreef,

It depends on the data source you're using. The ? will work with databases like Access, while the @name works with SQL Server.

The [] are used to enclose database objects that have (semi) invalid names, containing reserved words or spaces. Enclosing the name in [] tells the database to take the text between them as literal text.

I am not sure if your second example works; may work on other databases...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old June 5th, 2006, 07:51 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
Insert command rajanikrishna ASP.NET 1.0 and 1.1 Basics 0 April 3rd, 2006 08:47 AM
Command Builder BSkelding ASP.NET 1.0 and 1.1 Professional 3 April 18th, 2005 12:03 PM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM





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