Questions tagged [sqlcommand]
Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database which is used in Microsoft .NET.
sqlcommand
925
questions
0
votes
0
answers
49
views
Sanitising or Parameterisation of table name and columns in a SqlCommand [duplicate]
I am looking to build an internal tool that allows the generation of data in a database from a GUI, of course with a parameterised query if the tables and columns are known beforehand, this is no ...
0
votes
0
answers
72
views
'The SelectCommand property has not been initialized before calling 'Fill'. ' error
I'm trying to have a DataGridView in my Windows Forms showing data from the database, but it doesn't want to run.
namespace DentalClinicManagementSystem
{
class MyPatient
{
public void ...
0
votes
0
answers
32
views
SSIS Deployment Error: DataReader Issue When Executing Truncate Table SQL Command Task from SSISDB in SQL Server
I have a package containing a SQL Command task that truncates a table in SQL Server. When I executed it in the Visual Studio platform, the execution was successful. However, upon deployment and ...
0
votes
0
answers
135
views
C# Unit Test : How can I mock Database GetDbConnection() CreateCommand?
I've set up a mock database that works well - allowing me to test IF Statements below BUT line 55 calls a method that ultimately uses SQL to retrieve data from a database. So when the test progresses ...
-1
votes
1
answer
221
views
Dapper convert DbNull to empty string
I am refactoring some code that used reflection to map a SqlCommand to a model. The new code uses the Dapper framework and works perfectly fine:
Public Shared Function GetModel(Of T As New)(cmd As ...
1
vote
1
answer
323
views
How to show the backslash commands in PostgreSQL?
With \help or \h below, I could show the SQL commands as shown below:
\help
Or:
\h
postgres=# \help
Available help:
ABORT CREATE USER
ALTER AGGREGATE ...
1
vote
1
answer
60
views
Chapter 4 case project
Create a view named HighBalance using the the patient number, last name, first name, street, city and zip code for those patients with a balance greater than $1,000. Display the data in the view
Im ...
0
votes
1
answer
79
views
Getting values from C# SqlDataReader into an integer variable
I am using SqlCommand to run a simple query against my database:
SELECT MIN(ID), MAX(ID)
FROM DocumentImage
Obviously the query should return one row with two columns a minID (1) and a maxID (...
0
votes
0
answers
99
views
C# Additional String Validation For .text
I'm trying to figure out on the proper way for the additional string validation. I have an SQL query below which is compiled on c#, detected by Checkmarkx application that the Row.Cells[2].Text is not ...
-1
votes
1
answer
97
views
Wrong output parameter read from T-SQL stored procedure [duplicate]
I have to read a value from a simple T-SQL stored procedure. When I test the procedure in SQL, it works fine.
But when I try to read by a C# SqlCommand, it returns a wrong value that is always 0 (zero)...
0
votes
4
answers
103
views
How to remove duplicate rows with the same column in SQL
I have the following table in SQL:
I want to remove rows with the same id value.
Which query in SQL should I use?
The table should be as follows after the delete operation:
0
votes
2
answers
98
views
How can i write raw SQL commands in EntityFramework 6
I'm trying to do a raw SQL statement which resembles this
DELETE FROM db.T0590_CODE_STRING WHERE IN (1,1,2,3,5)
the values in the IN clause are from rowIds list so therefore I'm trying to use a ...
0
votes
1
answer
38
views
Adding variable in SQL command not working with Select statement
Code:
x = int(id_[0])
select_query = "SELECT * FROM files WHERE id = %s"
cursor.execute(select_query,x)
results = cursor.fetchone()
I am using mySQL in Python. This is the error I get:
...
0
votes
1
answer
82
views
C# string to number
I want to store to a column a value from string to number
I have this part of code in c#
//Order
string refId = order.id.ToString();
ApplicationLogger.Write("order.date_created : " + order....
0
votes
0
answers
399
views
SQL Server throwing error on valid SQL - incorrect syntax near 'and'
I have a data transformation application where one of the first steps is for the user to paste in a valid SELECT statement. After it is verified, the app will execute it against their database and ...