Delete Data
-
Hi, I want to delete data from datbase by entering a year in text box. If the there no data then i want to show "the selected date does not exist". How can i do this? pls help me? Please write code here........................
It should look something like this. SqlConnection con = new SqlConnection(connecitonstring); SqlCommand cmd = new SqlCommand("delete from table where year = @year",con); cmd.Parameters.Add("@year",SqlDbType.Int).Value = int.Parse(TextBox1.Text); if(cmd.ExecuteNonQuery() > 0) { Console.WriteLine("Record deleted successfully"); } else { Console.WriteLine("No data found"); }
-
Hi, I want to delete data from datbase by entering a year in text box. If the there no data then i want to show "the selected date does not exist". How can i do this? pls help me? Please write code here........................
in select statement strdelete="delete from tablename where datefield='date' objsqlconn=new sqlconnection("user id=sa;password=;data source=servername") objsqlconn.open try Dim vbmsg As String vbmsg = MessageBox.Show("Are u sure to delete this record", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Information) If vbmsg = vbYes Then strdelete = "delete from tablename where datefield='date'" objsqlcmd = New sqlcommand(strdelete, objsqlconn) objsqlcmd.executenonquery() Else MessageBox.Show("There is no field exits") End If catch (ex as exception) exception(ex.message) end try
-
Hi, I want to delete data from datbase by entering a year in text box. If the there no data then i want to show "the selected date does not exist". How can i do this? pls help me? Please write code here........................
yes
-
yes
rohitsrivastava wrote:
yes
:confused:
Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website
-
rohitsrivastava wrote:
yes
:confused:
Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website
Why do I get the feeling the OP is going to copy'n'paste the code thrown at him and wonder why it doesn't work?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007