473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DeleteCommand

Hello,

How can I use the DeleteCommand to delete a record where the delete statment
takes a CustomerID as a parameter (CustomerID is the variable that holds
Customer ID taken from a TextBox)

Thanks
--
Regads,
Rochdi
Nov 21 '05 #1
1 1265
"John" <Jo**@discussions.microsoft.com> schrieb:
How can I use the DeleteCommand to delete a record where the delete
statment
takes a CustomerID as a parameter (CustomerID is the variable that holds
Customer ID taken from a TextBox)


Sample (look for "DELETE FROM"):

..NET Framework Class Library -- 'SqlDataAdapter' Constructor ('SqlCommand')
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlDataAdapterClassctorTop ic2.asp>

Note that this sample shows how to use a parameterized command. This
approach is recommended over building up the whole command string by hand
because it protects from SQL injection.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
0
by: Christopher Weaver | last post by:
Using VS 2003: My odbcDataAdapter.DeleteCommand.CommandType is StoredProcedure. The call is returning an error indicating that my SP doesn't return a value. Does it have to? I don't need one,...
2
by: Peter Afonin | last post by:
Hello: I'm deleteing data using Datagrid, then rebind it. For some reason ItemDataBound event doesn't fire after DeleteCommand. Why is this? Is it by design, or I'm missing something? I have...
4
by: Rodger Dusatko | last post by:
After entering the sql statement da.deletecommand.commandtext = "Delete from Users where username = @username" I set the parameter to the username I wish to delete. This successfully deletes the...
4
by: Nathan Sokalski | last post by:
I have a DataList that has an Button as one of the controls in it's ItemTemplate. The Button has a CommandName="delete" attribute, but when I click it the DeleteCommand event doesn't even get...
2
by: phil | last post by:
Hi, The connection and DeleteCommand of a gridview are defined in the aspx file like this: <asp:SqlDataSource ID="SqlDataSource1" runat="server"...
1
by: Jason Barnett | last post by:
I dropped a DataGrid control onto a Web UserControl (.ascx) and added columns for Editing and Deleting data. At first, I had everything working; when the edit button was clicked the row entered...
0
by: jobs | last post by:
Gridview with datasoure with deletecommand. Why do I need an event handler? Isn't this enough? I know this code has worked when I use a fielditemtemplate <asp:GridView ID="RouteGridView"...
1
by: renatois | last post by:
DeleteCommand in SqlDataSource using DetailsView Hi guys, Figure that: - I have two related tables by IDName: 1 - table Name (fields: IDName, Name) 2 - table Products (fields: IDProduct,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.