sqlcommand Questions
7
Solved
I'm trying to insert a database record inside a loop in C#.
It works when I hard code the values like this:
string query3 = "INSERT INTO furniture (room_id,member_id) VALUES (222,333);";
SqlCom...
Vincenty asked 5/1, 2012 at 17:41
4
Solved
I have a stored procedure that executes much faster from Sql Server Management Studio (2 seconds) than when run with System.Data.SqlClient.SqlCommand (times out after 2 minutes).
What could be the...
Fernferna asked 29/4, 2009 at 11:26
3
I have a C# desktop app that calls various SQL Server stored procedures to perform various work of exporting and importing data to a SQL Server 2008 R2 database.
These all work fine, no problem. A...
Stool asked 25/3, 2013 at 16:20
3
Solved
Am looking to use an approach in saving passwords that requires using byte array as in this post
So which data type should i use in sql server to save byte array? and how can i pass and retrieve t...
Achieve asked 20/3, 2013 at 7:51
1
Solved
I have a few functions that use the SqlCommand object to to data inserts, and queries. But one function (the last one in the file) seems to echo (most of) the attributes into the output. The functi...
Boyish asked 29/3, 2016 at 19:9
7
What's the best way to INSERT data into a database?
This is what I have but it's wrong..
cmd.CommandText = "INSERT INTO klant(klant_id,naam,voornaam) VALUES(@param1,@param2,@param3)";
cmd.Parame...
Devise asked 17/10, 2012 at 17:0
11
In terms of SQL injection, I completely understand the necessity to parameterize a string parameter; that's one of the oldest tricks in the book. But when can it be justified to not parameterize an...
Lambent asked 18/9, 2015 at 2:2
1
Solved
From msdn website I get the following:
A special data type for specifying structured data contained in table-valued parameters.
It seems my code works with it and without it (pushing table to ...
Conglobate asked 6/7, 2015 at 15:58
6
Solved
I'm building a custom db deployment utility, I need to read text files containing sql scripts and execute them against the database.
Pretty easy stuff, so far so good.
However I've encountered a...
Bonni asked 16/3, 2010 at 17:15
4
Solved
I have a datatable with around 3000 rows. Each of those rows need to be inserted in a database table. Currently, i am running a foreach loop as under:
obj_AseCommand.CommandText = sql_proc;
obj_As...
Biafra asked 5/1, 2015 at 6:10
5
Solved
In my table I have some colms like this, (beside another cols)
col1 | col2
s1 | 5
s1 | 5
s2 | 3
s2 | 3
s2 | 3
s3 | 5
s3 | 5
s4 | 7
I want to have average of ALL col2 over Distinct col1.
(5+3+5+7...
Candelaria asked 15/10, 2014 at 7:53
4
Solved
I have seen this show up several places in code, never with an explanation, just a cryptic comment above it (Declaration and execution included for an idea of context. It's just a standard procedur...
Nonconformity asked 17/8, 2010 at 19:5
1
Solved
I am having an issue getting the following code to correctly add the SqlCommand parameter @vendor. For some reason, the query being passed seems to always be:
select TOP 500 *
from [mike_db...
Linkwork asked 12/8, 2014 at 1:45
4
Solved
I've been using the SqlCommand class and writing my own T-SQL queries for a very long time. I've stuck with it because I'm comfortable with it, and it probably stemmed from me starting as a w...
Cachou asked 16/7, 2014 at 5:58
2
I am trying to pass a table name as a parameter to my query through SqlCommand but it doesn't seems to be working.
Here is my code;
SqlConnection con = new SqlConnection( "server=.;user=sa;passwo...
Cliff asked 29/4, 2014 at 6:50
1
Solved
I have two queries:
Q1: select name from presidents where country = 'USA'
Q2: select 'Obama' as name from presidents where country = 'USA'
When using System.Data.Odbc.OdbcCommandExecuteReader th...
Catron asked 5/3, 2014 at 10:7
2
Solved
I've searched around the internet and everything seems to be about individual fields or doing one insert. I have a migration tool that is migrating from an old legacy database (superbase) to our SQ...
Deshawndesi asked 27/1, 2014 at 20:4
1
Solved
When should I use Parameters. Add/AddWithValue?
In the following MSDN example they use Parameters.Add for int and Parameters.AddWithValue for string
command.Parameters.Add("@ID", SqlDbType.I...
Pammy asked 14/1, 2014 at 9:31
3
Solved
I am using an ADO.NET SqlCommand with a single SqlDbType.Structured parameter to send a table-valued parameter to a sproc. The sproc returns many rows, which I need to get into a strongly-Typed Lis...
Elseelset asked 17/5, 2011 at 16:58
2
Solved
I have about 1.5 million files I need to insert records for in the database.
Each record is inserted with a key that includes the name of the file.
The catch: The files are not uniquely identified...
Liquidity asked 18/9, 2013 at 15:33
3
Solved
I'm having a difficult time understanding "on delete cascade"
If I had the following example:
create table X (id int primary key, name char(10));
create table Y (bid int primary key, aid referenc...
Lemire asked 16/9, 2013 at 17:54
1
Solved
The default CommandTimeout value is 30 seconds. You can manually change the value on an instance of the command object by doing the following
Dim cmd As New System.Data.SqlClient.SqlCommand
cmd.Co...
Rewrite asked 6/8, 2013 at 20:26
5
Solved
when I enter this
INSERT INTO works_on
(essn, pno, hours)
values
('123456789', 1, 32.5),
('123456789', 2, 7.5),
('666884444', 3, 40.0),
('453453453', 1, 20.0),
('453453453', 2, 20.0),
('333445555'...
Offen asked 25/6, 2013 at 2:54
1
Solved
I have a problem when I want to delete an entire row based on id_curse. This is my code and this is my error I get:
An unhandled exception of type 'Oracle.DataAccess.Client.OracleException' occu...
Braud asked 20/6, 2013 at 10:59
2
Solved
I'm adapting some code that someone else wrote and need to return a DataTable for time's sake.
I have code like this:
using (SqlCommand command = new SqlCommand(query, conn))
{
//add parameters ...
Colver asked 14/12, 2012 at 0:17
© 2022 - 2024 — McMap. All rights reserved.