|
-
Jun 4th, 2003, 07:21 AM
#1
Thread Starter
yay gay
deleting a row from a mssql database
how do i do this in asp.net? i am quite new to SQL programming so i dont really know how to do it...in C# i've tried this just for testing purposes..:
Code:
SqlConnection connection = new SqlConnection(CONNECTION_STRING);
connection.Open();
SqlCommand command = connection.CreateCommand();
command.CommandText = "DELETE * FROM DailyDev";
int res = command.ExecuteNonQuery();
connection.Close();
but i am gettin a "System Error"
what am i doing wrong? also how is the fastest way to access the database and delete the records..i am doing in a way its too slower?
feedback appreciated!
\m/  \m/
-
Jun 4th, 2003, 07:53 AM
#2
Frenzied Member
this way seems to be fast and efficent...
VB Code:
Dim strConnection As String = "Provider=MSDAORA;Password=" & password & ";User ID=" & userid & ";Data Source=" & database
Dim strSQL As String = "delete from pbss.pbss_bid_schedule where bid_id ='" & ID & "'"
Dim objConnection As New OleDbConnection(strConnection)
Try
Dim objCommand As New OleDbCommand(strSQL, objConnection)
objConnection.Open()
objCommand.ExecuteNonQuery()
Catch ex As Exception
lblMsg.Text = ("Delete Error " & Err.Description)
objConnection.Close()
Finally
objConnection.Close()
End Try
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
Jun 4th, 2003, 10:00 AM
#3
Fanatic Member
"delete * .....
should just be
"delete .....
the best way to delete all data is to drop the table, and then re-create it using a stored procedure that you will have already created (u can use stored procedures to create tables).
-
Jun 4th, 2003, 10:52 AM
#4
Hyperactive Member
Originally posted by nswan
"delete * .....
should just be
"delete .....
the best way to delete all data is to drop the table, and then re-create it using a stored procedure that you will have already created (u can use stored procedures to create tables).
No offence but that's not such a good approach in a multi-user environment among other reasons.
Other users may get errors when the table is dropped.
I doubt the drop transaction could be rolled back if necessary.
Also there's considerable overhead wifh freeing up the table resources and then recreating them.
IMO much better to stick with the DELETE cmd...
-
Jun 4th, 2003, 02:30 PM
#5
Fanatic Member
no i agree it's not the best way to do it but if you want to delete all data from a large table with lots of records it's the quickest.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|