473,412 Members | 2,092 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,412 software developers and data experts.

SQL Delete Command??

Hi

I need to run a delete query from my application... is there a quick way of
doing this other than setting up an adapter and running the stored
procedure?? etc...

something like the VB6 database.Execute(SQLStatement) would be perfect... if
not i'll just do i the normal way.

Thanks
Regards
Nov 16 '05 #1
3 10557
hi
you can use DataAccessApplicationBlock Provided by microsoft .
It can be downloaded and used . It saves some code.

http://msdn.microsoft.com/library/de...ml/daab-rm.asp

regards
Ansil

Dimensions
Technopark
Trivandrum
an****@gmail.com
"Darryn Ross" wrote:
Hi

I need to run a delete query from my application... is there a quick way of
doing this other than setting up an adapter and running the stored
procedure?? etc...

something like the VB6 database.Execute(SQLStatement) would be perfect... if
not i'll just do i the normal way.

Thanks
Regards

Nov 16 '05 #2
Hi Darryn,

Yes sure u can excete delete query direct using command object.

'1. Create a connection
Dim myConnection as New SqlConnection("connectionString")

'2. Create the command object, passing in the SQL string
Const strSQL as String = "Delete ..."
Dim myCommand as New SqlCommand(strSQL, myConnection)

myConnection.Open()
myCommand.ExecuteScalar(CommandBehavior.CloseConne ction)
"Darryn Ross" wrote:
Hi

I need to run a delete query from my application... is there a quick way of
doing this other than setting up an adapter and running the stored
procedure?? etc...

something like the VB6 database.Execute(SQLStatement) would be perfect... if
not i'll just do i the normal way.

Thanks
Regards

Nov 16 '05 #3

"Darryn Ross" <da****@datawave.com.au> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
Hi

I need to run a delete query from my application... is there a quick way of doing this other than setting up an adapter and running the stored
procedure?? etc...

something like the VB6 database.Execute(SQLStatement) would be perfect... if not i'll just do i the normal way.

Thanks
Regards


You need to set up a connection to your database, which here is referenced
by oleDbConnection1, this code is for an OLEDB connection but this can
easily be replaced by the SQL version.
string strDelete = "DELETE FROM [yourDatabase] WHERE [yourField] = '" +
yourArgument + "'";
OleDbCommand cmd = new OleDbCommand(strDelete, oleDbConnection1);
try
{
oleDbConnection1.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
oleDbConnection1.Close();
}
Nov 16 '05 #4

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

Similar topics

3
by: sql-db2-dba | last post by:
There are 2 tables A and B with A being the parent of B. Table A ( Col1 varchar(5) Not Null ) Table B ( B_PK varchar(5) Not Null ,
9
by: Toralf Kirsten | last post by:
Hi, we installed db2 v8.1 on red hat linux 9. Unfortunately, the backspace and the delete button doesn't work in the right way. Instead of deleting chars, control characters are inputed. That...
9
by: Melissa | last post by:
What is the code to delete a command button from a form? Can the code be run from the click event of the button to be deleted? Thanks! Melissa
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
5
by: Neil | last post by:
I am getting time-out errors when I try to perform a simple delete on a linked server. The command is: Delete From MyTable Where PKID=12345 I have tried executing this command directly from...
3
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
1
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
10
beacon
by: beacon | last post by:
Hi everybody, This is probably going to sound unorthodox, but I have to log records that are deleted...I know, go figure. Anyway, I have a form with a (continuous) subform, and on the subform I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.