Tag: ado.net

SSMS SMO Objects: Get query results

I came across this tutorial to understand how to execute SQL scripts with GO statements. Now I want to know what can I get the output of the messages TAB. With several GO statements, the output would be like this: 1 rows affected 912 rows affected … But server.ConnectionContext.ExecuteNonQuery() can return only an int, while […]

Connect ASP.NET WebSite to SQL Database

I am currently trying to establish a connection between an ASP.NET web site project and a Database built by SQL Server 2008 R2. The way I am required to do so is to use the connectionString from the Web.config page, but I have no idea what value to give it or how to establish a […]

IGNORE_DUP_KEY option in SQL Server

I did quite some search in MSDN and Google, but looks like the description for IGNORE_DUP_KEY option is very limited. My confusions, Is IGNORE_DUP_KEY option an option for a column? for a table? for a couple of columns? for an index (making index unique)? If set IGNORE_DUP_KEY to Yes, when insert a batch of records […]

Get Relations of a Table

I want to get relations (or foreign keys) of a Sql Server Table in my c# code. How can i do this? Thank you

Detach database programmatically

I have a database “D:\MDF CONNECTION SAMPLE\BIN\DEBUG\HARMDATABASE.MDF”. I am trying to detach or rename it, with this code: SqlConnection conn = new SqlConnection(“Data Source=.\\MSSQLSERVER2008;database=Master;Integrated Security=True;”); SqlCommand cmd = new SqlCommand(“”, conn); cmd.CommandText = @”sys.sp_detach_db D:\MDF CONNECTION SAMPLE\BIN\DEBUG\HARMDATABASE.MDF”; conn.Open(); cmd.ExecuteNonQuery(); cmd.Dispose(); conn.Dispose(); But getting an error: Incorrect syntax near ‘\’.

Get the value of print statement of sql server in vb.net by using oledb

I am trying to create an query analyzer and executor. I wonder that how to get the output message of an transact-sql statement like ‘PRINT’ declare @msg varchar(100) set @msg = select [column] from [table name] where [column] = [condition] if @msg = ‘SOMEVALUE’ begin print ‘This is first statement’ end else begin print ‘This […]

SNIReadSyncOverAsync Performance issue

Recently i used dot Trace profiler to find the bottle necks in my application suddenly i seen that in most of the places which is taking more time and more cpu usage too is SNINativeMethodWrapper.SNIReadSyncOverAsync() which is called by Execute reader method of ADO.Net , I don’t know why it’s taking more time. If i […]

How can I use single query to insert multiple records from Dataset into SQL Server 2005?

I have a dataset in ADO.NET containing multiple records from user side. I need to insert all those rows in single query into the database, in order to avoid multiple queries

ADO.Net SQLCommand.ExecuteReader() slows down or hangs

Environment: Application (written in C# for .Net 4) has up to 10 threads, each thread runs in its own AppDomain. Each thread uses a ADO.Net DataReader that gets the results from the stored procedure on SQL-Server 2008. Also a thread can use ADO.Net to perform a write operation (Bulk Insert). Everything runs on the local […]

Create new SQLCommand's or reuse the same one

I need to send a list of commands to SQL 2008 using ADO.NET, to be executed one after the other. Should I create a new SQLCommand for each SQL that I’m sending? Or reuse the same SQLCommand and just change the CommandText property? Thanks, Nestor

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.