Easier way to send parameterised query to database?
问题 Is there a way to write the following code in less lines? It seems like a lot of code to execute such a simple query. No LINQ as I am using VS2005. Answers in either VB or C# are acceptable. Using cmd As DbCommand = oDB.CreateCommand() cmd.CommandText = "SELECT * FROM [Table1] WHERE [Date] BETWEEN @Date1 AND @Date2" cmd.CommandTimeout = 30 cmd.CommandType = CommandType.Text cmd.Connection = oDB Dim param As DbParameter param = cmd.CreateParameter() param.Direction = ParameterDirection.Input