What exactly does cmd.ExecuteNonQuery() do in my program

string connection = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=D:\it101\LoginForm\App_Data\registration.mdb"; string query = "INSERT INTO [registration] ([UserID] , [Name] , [Contact_no] , [City]) values (123, 'abc' ,12345, 'pqr')"; OleDbConnection con = new OleDbConnection(connection); OleDbCommand cmd = new OleDbCommand(); cmd.CommandText = query; cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); And what if i do not write cmd.ExecuteNonQuery() at the end … Read more

Good practice to open/close connections in an asp.net application?

I’ve been working on a web application in ASP.net. My application has several pages and all of them need to display tables that are populated by a database. Right now what I’m doing is, on each page, I’m opening a database connection, executing the query specific to that page, and closing the db connection. So this happens each time the user clicks a link to go to a new page or clicks a form control like the grid page.

How to automatically delete records in sql server after a certain amount of time

I have set up temporary user accounts on my sql database where the user names, passwords and date added of my websites users are stored. I was initially going to have these records delete programmatically but now im wondering if sql server 2008 has a built in function that allows records to be auto-deleted after … Read more

MySQL Database Connection With Visual Studio 2013 Preview

I was using Visual Studio 2013 Preview but I couldn’t find MySQL database in the “choose data source” dialog window, I even installed the latest version of MySQL connector as well as the windows MySQL installer (to get MySQL plugin for visual studio) but nothing changed, I had to get back to VS 2012 Ultimate, I just wanted to know if there is a special MySQL connector for the 2013 Preview Edition?

Attempt to attach an auto-named database for .mdf file failed

I am currently building a Web Application Project in Visual Studio 2010 and, until recently, have not needed to use the scaffolded code for Memberships, Users and Roles etc that are stored in the ASPNETDB.mdf database file. I have been running the project on the Visual Studio Web Server, IIS Express (from Visual studio) and also IIS7.5 without a problem.