Tag: ado.net

Retrieve number of columns in SQL Table – C#

I’m very new to C#. I’m trying to retrieve the number of columns using: SELECT count(*) FROM sys.columns Could you please explain how to use the command and put it into a variable.

“The transaction has already been implicitly or explicitly committed or aborted” in transaction scope

I have a web server and two DB servers on two different networks, Db1 and Db2(Remote Database). DB1: SQL Server 2008 R2, operating system: Windows Server 2003 SP2 DB2: SQL Server 2000, operating system: Windows Server 2003 R2 Web server: Windows Server 2003 R2 I want to insert two different records in these databases and […]

SPID of a SqlConnection (SQL-Server) in ADO.NET

Can I get a SPID from a SqlConnection Object (SQL-Server Database) in ADO.NET? Is the SPID always the same for a connection object during its lifetime ?

Synchronize DataSet

What is the best approach to synchronizing a DataSet with data in a database? Here are the parameters: We can’t simply reload the data because it’s bound to a UI control which a user may have configured (it’s a tree grid that they may expand/collapse) We can’t use a changeflag (like a UpdatedTimeStamp) in the […]

Testing custom ORM solution performance overhead – how to?

I have created a prototype of a custom ORM tool using aspect oriented programming (PostSHarp) and achieving persistence ignorance (before compile-time). Now I tried to find out how much overhead does it introduce compared to using pure DataReader and ADO.NET. I made a test case – insert, read, delete data (about 1000 records) in MS […]

Error: The conversion of a nvarchar data type to a smalldatetime data type resulted in an out-of-range value

Hey all I’m trying to do the following insert query SqlDataSource userQuizDataSource = new SqlDataSource(); userQuizDataSource.ConnectionString = “Data Source=localhost\\SQLEXPRESS;Initial Catalog=quizApp;Integrated Security=True”; userQuizDataSource.InsertCommand = “INSERT INTO [UserQuiz] ([DateTimeComplete], [Score], [UserName]) VALUES (@DateTimeComplete, @Score, @UserName)”; userQuizDataSource.InsertParameters.Add(“DateTimeComplete”, DateTime.Now.ToString()); userQuizDataSource.InsertParameters.Add(“Score”, score.ToString()); userQuizDataSource.InsertParameters.Add(“UserName”, User.Identity.Name); int rowsAffected = userQuizDataSource.Insert(); Buti keep getting the following error: The conversion of a nvarchar data […]

Force the TCP/IP protocol in connection string

i have a database driven website written in asp.net. i’d like to modify the connection string to force protocol TCP. Please advise. Thanks!

Overflow exception when reading decimal values from SQL Server

I’m wondering whether this is a bug or if I’m going something wrong. I’m loading values with a SqlDataReader from a SQL Server 2008 database but under certain circumstances, it fails to convert the SQL values into .net values. (.NET 4.0) I have traced it down to an test-case which demonstrates the actual problem: Working […]

How do I access SQL Server from Windows 8 apps?

I realize that a local SQL Server instance is not accessible to my Windows 8 app. Instead, I have a SQL Server in Azure. In SQL Server Management Studio, I just change the querystring and interact with the Azure database like any other. How can I reference that database in my Windows 8 app?

EF Code First: Cannot connect to SQL Server

I am trying to create a database using code-first approach. When I am running the following code I am getting the following exception. How can we overcome this? Notes: I have SQL Server 2008 R2 on my system. I am not using any config file. I assumed that it will create database using conventions There […]

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