Questions tagged [c#]

C# is a general-purpose, managed, garbage-collected, object-oriented programming language created by Microsoft.

Filter by
Sorted by
Tagged with
0
votes
1answer
171 views

Select data from a table and update a second table using most recent value [closed]

I have two table: Stampings and Registries. Stampings is populate from a program that read a CSV file and do an insert into the table. Some field into the table are: name, surname, card-code and ...
0
votes
3answers
114 views

SQL Server FullText searching on text that is slightly obfuscated before insert

Our app slightly obfuscates text before insertion to the database. This is done by the application (C#) and not the database. (This is not encryption but just to stop people who are looking at the ...
2
votes
0answers
496 views

C# Windows Service task fails due to a SP timeout, but works fine after executing the SP in SSMS

I have a Windows Service app running and sometimes a task which has a method call to a stored procedure (with a Select operation) is keep failing due to a timeout. But when I execute that SP with ...
7
votes
1answer
638 views

Why would a foreign key from a table to itself cause a deadlock when running two deletes?

I have a database with a table "SelfRef". SelfRef has two fields: Id (guid, PK, not null) SelfRefId (guid, nullable) There is a foreign key constraint that maps the SelfRefId field back to the Id ...
2
votes
1answer
520 views

Sleeping connections

I have a dedicated MySQL server(8GB) with following configuration. [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql lower_case_table_names = 1 default-storage-engine=...
1
vote
1answer
156 views

Joining tables on DB server vs App-Backend server

I have two tables stored on the DB server. I need to join these two tables and perform further calculations. I am sure that the calculations part should be done on backend server. But I am wondering ...
0
votes
1answer
764 views

Create a maintenance plan for sql database with C#

We are planning to create c# jobs that perform some database maintenance actions such as backup, shrink files etc... I have read in many blogs that database shrink is not recommended and thats why I'...
3
votes
3answers
2k views

AddWithValue performance and plan cache implications

Recently I noticed my company's application using AddWithValueto pass parameter values to dynamic, parameterized queries. Example: cmd.Parameters.AddWithValue("@VehicleId", Vehicles.VehicleId); In ...
0
votes
1answer
385 views

What is a staging table and how do you protect data loss when transferring the data?

What is a staging table? What is it used for? Are there best practices that should be applied? I'm working in Oracle right now. Are staging tables platform dependent? I'm performing a bulk copy with ...
6
votes
3answers
10k views

Pass datatable as parameter in PostgreSQL

I have one datatable in asp.net C#. And I want to pass that datatable into PostgreSQL function as a table parameter. How is it possible? Below example is same but it is in SQL Server. I need same ...
5
votes
2answers
2k views

What's the best practice of inserting a collection of data into a SQL Server database

I am using C#, Entity Framework. SQL Server for the development. I have a method which has two parameters (int ID, List<String> _listobj). For each ID, there is a list of obj. All of these IDs ...
1
vote
0answers
229 views

SSIS log subcomponent name

I want to log information using a 2016 SSIS C# (2015) script task that will be easily findable in my SSIS reports I have built. My plan is to use the IDTSComponentEvents.FireInformation method, and ...
6
votes
2answers
15k views

sql server , set N prefix as unicode for all queries by default

Is there any option in ms sql server which use N prefix for my database. There are many query in my application which non of them use N prefix for nvarchar fields , and now I have to set N for all of ...
0
votes
1answer
321 views

Arithmetic Overflow at RunningPackages (SSIS) problem [closed]

I've developed an SSIS Package with the C# Code.All the Package were running fine.But for the past 2 days, we are experiencing public void Main() { // TODO: Add your code here ...
2
votes
2answers
48 views

Report individual changes to data

I need to produce a daily extract on the individual changes to a dataset. So, there are 14 tables containing product and customer information and the extract must only show records from each table ...
3
votes
1answer
4k views

Unable to connect using Azure AD Service Principal on SQL Server

I'm having trouble testing a connection to Azure SQL Server using SSMS with an active directory service principal. I have an AD Admin account created, and have successfully added a colleague's AD ...
4
votes
2answers
967 views

Timeout expired SqlException for complex Procedure

I use Sql Server 2008 R2 and ASP.NET 4.5. Sometimes, I get this error when I executed a complex procedure: System.Data.SqlClient.SqlException Timeout expired. The timeout period elapsed ...
7
votes
2answers
1k views

Why can't C# SMO see extended properties on a column but Powershell SMO can?

I am attempting to read extended properties on tables and columns in a winforms C# application. I am using SQL Server SMO to do so. When I execute the application it does not see the extended ...
-3
votes
1answer
144 views

SQL Server database chooser

I remember I used to use a tool that displayed a form so that any reachable database could be selected, like the initial prompt when you open SSMS. I don't remember if it's a StackOverflow tool, ...
1
vote
2answers
602 views

How to copy data from one database to another database efficiently?

I have a conceptual question. I have two databases which theoretically have the same structure but one of them is a SQLBase database and the other one is a SQL Server database. One database (the ...
2
votes
0answers
551 views

What to do when you find slow running query?

I have two databases. One with 10.000 rows and one with 10 million rows. I have a load test and I am running it towards a rest api endpoint. This endpoint does a query to database and average ...
1
vote
2answers
2k views

Getting the metadata about a Query and a Stored procedure in SQL Server

I would like to get all the names of the columns in a given query [SQL Textual Query] and also the columns that are in the SELECT clause in a Stored Procedure. Is there any ways other than using ...
-1
votes
2answers
684 views

Get compressed data from sql server database to application

I have created a C# application. I have used sql server database for this application. When i run the application it communicate with the sql server and retrieve data. My problem is that when ...
2
votes
1answer
962 views

SSIS append trailer with Script

I am trying to add a footer to a flat file output. I have 2 data flows in my control flow. One creates the file from the DB. It goes from OLE DB Source to Flat File Destination. The second control ...
1
vote
2answers
3k views

c# Backup sql server database, error Operating system error 5(Access is denied.)

I have been trying to backup an sql server database, and I understand that this error is in regards to drive write protection. I am at the end of my rope with this, as nothing that I have found online ...
1
vote
1answer
3k views

Asynchronous database inserts from C# always result in a deadlock

I'm hoping this doesn't come off as too amateurish, but I'm converting a synchronous program to run asynchronously. So far, I've gotten everything running asynchronously except database inserts. ...
0
votes
1answer
482 views

Query fails from application but runs fine in SSMS

I have a query that runs fine when executed from SSMS but when done so from the application, it fails with a (database level) exception. select ksprintid from kshistory_akt h where cast(h.serialno as ...
3
votes
2answers
803 views

Can add one CLR function to SQL server but not a second in the same assembly: loading wrong DLL

With the following code, I used csc to compile the dll. I then added the assembly to sql server 2014 using CREATE ASSEMBLY ReplaceMultiWord from 'd:\bcp\ReplaceMultiWord.dll' WITH PERMISSION_SET = ...
14
votes
3answers
21k views

3rd party dll in SQL Server CLR

I need to use a third party DLL in a trigger c# code in SQL Server CLR But when I try to add reference it just shows some DLLs from SQL Server. How can I add my third party dll to SQL Server?
2
votes
1answer
654 views

SELECT COUNT(*) returns no data SQL Server 2012

I have a query, that as far as I know has failed exactly one time. It's a simple select count(*) from one table, no joins. But at least this once, executing that query resulted in no data read from ...
3
votes
2answers
3k views

A Dynamic where clause in MS SQL Server

The Problem My SQL Server database contains a view that looks like the following: +-------------+-----------+------+-------+------+------+ | CAR_ID | MAKE |COLOR | Miles | Seats| MODEL| +--...
0
votes
1answer
71 views

Procedure returning different values

I have a procedure TempSalesUpdateID which gets all ProductName's column in TempSales table and set it's corresponding ProductID. ALTER PROCEDURE [dbo].[TempSalesUpdateID] AS UPDATE T SET T....
2
votes
1answer
153 views

150 External flat files used to create internal DB

I have a situation in which I must create an entire DB off of ~150 external txt files (pipe delimited) which all represent unique tables. Furthermore these txt files come in daily and need to be ...
4
votes
3answers
10k views

What's the most efficient way to load a csv file into SQL Server 2016?

Alright, so this question seems simple up-front. Well, there's a bit more to it than just loading the file. The entire story goes like this: For some reason, our client sends us what can only be ...
3
votes
1answer
2k views

CLR Procedure with XML parameter returns Data at the root level is invalid. Line 1, position 1

I have following CLR stored procedure, which is throwing error on this command xmlDoc.LoadXml(inputXml); code public static int spGetTaxOfficeXML(SqlXml _inputXml) { // this ...
1
vote
4answers
1k views

Load testing: The performance of a query is decreasing as the number of parallel executions is increasing

I'm seeing a slow down when doing load testing on my app. I have a query that takes about 350ms to run, but what I run it in parallel 8 times (not to mention 32 times), it goes up to 2.5 seconds. I ...
3
votes
4answers
67k views

Converting varbinary data to varchar in SQLServer leads to unexpected results

I need to fix some data conversion issue in SQL server 2008. I got some requirement change on storing the data. Without much care I converted existing varbinary data to varchar using CONVERT(NVARCHAR(...
14
votes
1answer
8k views

Are we required to handle Transaction in C# Code as well as in stored procedure

Do we really require transaction handling in c# as well database store process both side C#: Using(transaction with transaction scope) { Execute stored proc; Transaction. Complete; } SQL ...
5
votes
1answer
3k views

SSIS 2012: What rights are needed to connect to SSDB via DMO

I'm trying to connect to the SSDB catalog to execute a package using the .NET object model e.g. using Microsoft.SqlServer.Management.IntegrationServices; var sqlConn = new SqlConnection(...
-1
votes
1answer
1k views

Can't connect to LocalDB from Visual Studio 2015

When I try to connect to the database, to which I was previously able to connect, I get the following error: I tried to solve this by looking up other stackoverflow questions and online resources, ...
0
votes
2answers
977 views

fetching Remote table data and storing into local dump file in pgSQL? [duplicate]

I want to copy one table's content from a remote machine to local. I have tried with psql Command \copy. It's working fine as "copy" is not working due to copying from remote. But is there any way I ...
2
votes
2answers
3k views

Grant execute on xp_logevent to sa using sa user to do it

Running a SQL Server 2012 CLR stored procedure with this code: const string executeLog = "EXEC master..xp_logevent @errorNumber, @message, informational"; using (SqlCommand cmd = new SqlCommand(...
0
votes
1answer
53 views

Best way to store products of Multiple Fields of different information

I have around 6 table in one of 3rd party cloud database. I am planning to Build it MSSQL. My problem in each of these table there are 20-40 field of different information and Item. Which approach ...
1
vote
1answer
171 views

Creating a Windows database backup service [closed]

I am creating a Windows service in C# that will run on our system to run a backup between 3am and 5am on our databases. I have started by creating a method that will basically run the backup when SQL ...
0
votes
1answer
929 views

How to setup sync between MongoDB and C# .NET Application

What is the best practice to synchronize a MongoDB remote database with a C# .NET App that would allow queries to be responded to within the local file system and update itself when there is a change ...
3
votes
1answer
3k views

Service Broker activation procedure in C# with external dependencies

I am not entirely sure if I have come to the right place, because this question involves both SQL Server and .Net. Apologies if this is not an appropriate place for my question! I am currently ...
7
votes
4answers
88k views

Login to SQL Server using Windows Authentication

I have an (.Net Console App) EXE which connects to various SQL databases using SQL server Authentication with appropriate credentials. Now there is change required in the EXE to use windows ...
2
votes
0answers
978 views

Using C#, is there a method to restore a database from a multi-file backup detecting which files are full vs diff?

I know there is functionality to restore databases in C#, however if I am given 2 or more files in a directory containing a full and differential backup files I would like to: 1) Determine which file ...
0
votes
1answer
905 views

How to make SQL Server order fields by 'Id' (which in this case is an Identity column)

I have an SQL Server table that i post into using C#. I would like the fields to be ordered using Id. Instead i get something like this: I need the id column to be arranged in order of increasing ...
1
vote
2answers
550 views

Understanding connection string syntax

I am following How To Create a SQL Server Database Programmatically but find limited resources explaining the syntax is greater detail other than MSDN: Filegroup Options. Take the following code on ...