Tag: ado.net

Use SqlDataReader and string array

I want to use data reader to read a record and send the result to an array string. I use a stored procedure to select data from 2 tables. string ReqID = “”; string ConnectionString = ConfigurationManager.ConnectionStrings[“ConnectionString”].ConnectionString; SqlConnection sqlc; string[] textbox; string ReqType; protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString[“ReqID”] != null) ReqID […]

Most efficient way to read XML in ADO.net from XML type column in SQL server?

With a XML type column in SQL server, what is the most efficient way to read this back into an XmlDocument in ADO.Net? For this particular use, an XmlDocument is needed for random-access to the loaded document. Using .Net 4.0 (C#) and SQL Server 2008 R2. Originally, we had a stored procedure that was returning […]

How is timezone handled in the lifecycle of an ADO.NET + SQL Server DateTime column?

Using SQL Server 2008. This is a really junior question and I could really use some elaborate information, but the information on Google seems to dance around the topic quite a bit and it would be nice if there was some detailed elaboration on how this works… Let’s say I have a datetime column and […]

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!

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