ado.net

C# - SQL Server - ? parameters and Oledb

I am writing a small framework in C# for importing data to SQL Server. I have noticed that if you try to use the ? placeholder for parameters, they do not work if you use the System.Data.SqlClient namespace. However, if you use the System.Data.OleDb namespace for working with the database, they work just fine. (you just have to add Pr...

What gets disposed when SqlCommand.Dispose is called?

In theory since SqlCommand implements IDisposable a SqlCommand object should always be disposed. I personally wrap a using statement around them. However I see lots of code that never disposes of SqlCommand objects without any apparent problems. I understand that finalizers will ultimately be called by garbage collection but since that ...

How to pass default keyword for table valued function call in ADO.NET

So here's the deal. In our database, we wrap most of our reads (i.e. select statements) in table valued functions for purposes of security and modularity. So I've got a TVF which defines one or more optional parameters. I believe having a TVF with defaulted parameters mandates the use of the keyword "default" when calling the TVF like s...

DataSet transformation to new DataSet group by (x)

I have DataSet. it returns date, and value by date. for ex: 01.01.2009 454 02.01.2009 785 03.01.2009 475 ---------- --- 30.01.2009 523 I need new DataSet, that group by week. for ex: 1 Week 1-7 2017 2 Week 7-15 4586 ----------------- 5 Week 24-30 1482 Week begin from monday. not importand only for this example, i...

How can I add multiple tables to dataset with Fill using IDataAdapter?

Hi, short question: Refering to http://stackoverflow.com/questions/170455/how-can-i-read-multiple-tables-into-a-dataset#answer-366402 My App has a db factory. Can i use 'da.Fill(ds)' [with IDataAdapter implementation] for multiple tables? Or how can i add more tables to the same DataSet. Copy the whole table would work but is this the o...

Smarter ways to use TableAdapter with base-class, interface or partial class.

C# ADO.Net TableAdapter objects does not implement and interface nor a base class (other than Component). Anyone used TableAdapter in a Template like (GoF-) pattern? Update: I would like to solve the problem described here: Help to improve a migration program by using template (GoF), adapter (GoF) or other nice patterns. ...

SQL Server and SqlDataReader - Trillion Records - Memory

I've never tried this - so I don't know if I'd run into memory issues. But can a SqlDataReader read a trillion records? It's all streamed correct? I'm a little green to what the SQL/TDS protocol is doing under the covers. UPDATE Translate Trillion to mean very large number. I probably should have said something like 1 billion or 100 mi...

import excel to sql db table

I am trying to write data from an excel spread sheet to a SQL Database. I have been able to connect to the Excel Spreadsheet and read the data but I am unable to get the data to insert into the SQL DB table. the current code is as follows any help most appreciated. Dim plmExcelCon As System.Data.OleDb.OleDbConnection Dim ldEx...

A special merge of datatables. (ADO.NET)

Hi, Say I have this existing code: datatable dt = new datatable(); for (i=0;i<...;i++) { dt = ..\\gets the i'th datatable somehow.Note: all datatables share the same scheme. DoSomethingWithDt() } ... What I want, is that at the end of this routine I will have ONE DATATABLE with the same scheme as those above, except for an ADDITIO...

Intercept/Log all database calls to SQL Server from a .Net Assembly

Is there a way to intercept/log all database calls from a .Net Assembly. The primary purpose is to log all TSQL statements generated and send to SQL Server database from any of the businss logic layer assembly. This mechanism should be available at global level and not required to be applied at each assembly. This mechanism should be unl...

Filemaker .Net Driver

I am not familiar with Filemaker, but I have inherited a Filemaker (I think v3) database. Is there an ADO.net or odbc driver I can use to extract data? ...

ADO.NET database access

I have written a program in VB.NET and one of the things this program does is insert records into a Microsoft Access database. The backend of my program that access the database is written as an interchangeable layer. If I "swap" this layer out with a layer that used a Microsoft SQL Server database, my program flies. If I use MS Access, ...

DataServiceQuery

Is there a GetTable or similar method on The ado.net dataserviceContext object in silverlight. I need to write a generic query builder to aid my silverlight LOB app. This could carve the workload in half. I already use expression trees passed in from Lambdas for the Where clause, it would just be could to be able to specify the entity w...

Object reference not set while SQL manager says it is

Lately I have run in a strange NullReferenceException. It pops up only occasionally why it is so hard to debug it for me. Today it happened again and I want to fix it now I have the error. I have the following setup: An asp.net view with relevant code: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WerkStageNu.Prof...

Detecting a -301 DB2 error in .NET

I have an application in VB.NET which is generating some -301 errors in DB2 on an update statement using an ADO.NET connection. It appears that DB2 reports the occurrence of this error, but then fixes whatever data was wrong and resubmits. This fixing and resubmission comes with additional overhead and in turn real dollars and cents cos...

Using Multiple T-SQL Statements in ADO.NET

Scripting in management studio with T-SQL works very well, but I am having a question about ADO.NET. I am able to code a simple select statement in ado.net. How to use the set statement in ado.net ? e.g. SET @polygon = (SELECT GEOM FROM Polygons WHERE NAME = 'Area1'); SELECT NAME FROM Points WHERE @polygon.STDistance(GEOM) <= .4; ...

SqlCeResultSet Problem

Hello, I have a SmartDevice project (.NetCF 2.0) configured to be tested on the USA Windows Mobile 5.0 Pocket PC R2 Emulator. My project uses SqlCe 3.0. Understanding that a SmartDevice project is "more carefull" with the device's memory I am using SqlCeResultSets. The result sets are strongly typed, autogenerated by Visual Studio 2008 ...

Why doesn’t Client-initiated Ado.Net transaction allow…?

Hi If we’re using client-initiated Ado.Net transactions, then when we try to execute a command that is not a part of current transaction while the transaction is underway, we’ll receive an error. Why is that? thanx ...

DataSet with multiple tables

Hello, I have a little problem. I don't know how to use the DataSet in VB.NET correctly. In Visual Studio 2008 I created a DataSet called Network. For the DataSet I took two tables from my database, tServer and tClient. tClient has a foreign key referencing the ID in tServer. After creating the DataSet I found a new namespace called N...

Why Returning false even if executes the stored procedure

public bool Update() { SqlParameter[] param = new SqlParameter[5]; param[0] = new SqlParameter("@EmpId", EmpId); if (string.IsNullOrEmpty(Name)) { param[1] = new SqlParameter("@Name", DBNull.Value); } else { param[1...