ado.net

How do I get the primary key of the row I just inserted into a typed dataset in .net?

I have some VB.net code that inserts data into my SQL database using a typed dataset as follows: dim usersTa As New authorizedUsersTableAdapters.Authorized_UsersTableAdapter usersTa.Connection = New Data.SqlClient.SqlConnection(MY_CONNECTION_STRING) usersTa.Insert(first_name, last_name) In the database, there is a primary key b...

How to track changes in many SQL Server databases from .NET application?

Problem: There are a lot of different databases, which is populated by many different applications directly (without any common application layer). Data can be accessed only through SP (by policy) Task: Application needs to track changes in these databases and react in minimal time. Possible solutions: 1) Create trigger for each ta...

How Can I Find What's Causing My Transaction to Get Promoted?

I have web site which serves web services (a mixture of .asmx and WCF) which is mostly using LINQ to SQL and System.Transactions. Occaisionally we see the transaction get promoted to a distributed transaction which causes problems because our web servers are isolated from our databases in such a way that it is not possible for us to use ...

C# SQL Data Adapter Fill on existing typed Dataset

I have an option to choose between local based data storing (xml file) or SQL Server based. I already created a long time ago a typed dataset for my application to save data local in the xml file. Now, I have a bool that changes between Server based version and local version. If true my application get the data from the SQL Server. I'm...

Build ATOM Feed Reader for ADO.net DATA Services feed

Hi, I have built an ADO.net data services to expose data in a SQL server database as XML. What I want to be able to do is create a feed reader for this ATOM feed in .net or may be a user control which subscribes to this URI based ATOM Feed from ADO.net data service & publishes the latest information on our website ...

Faster way to update 250k rows with SQL

I need to update about 250k rows on a table and each field to update will have a different value depending on the row itself (not calculated based on the row id or the key but externally). I tried with a parametrized query but it turns out to be slow (I still can try with a table-value parameter, SqlDbType.Structured, in SQL Server 2008...

C# SQL Data Adapter System.Data.StrongTypingException

I get my data from SQL to Dataset with Fill. It's just one table with two columns (CategoryId (int) and CategoryName (varchar)). When I look at my dataset after fill method, CategoryId Columns seems to be correct. But in the CategoryName I have a *System.Data.StrongTypingExceptio*n. What could that mean? Any Ideas? ...

Bulk Insert multiple records and get identity for all using ADO.NET

I want to batch insert multiple records in sql server database using ADO.NET command/sqldataadapter and get identity value generated for all the rows in a single database trip. What are my options? ...

Best Data Access Methods for New Web Application

I'm building a new web application project and am confused by the numerous methods of performing data access. I'm backending on SQL and a bit confused whether to use LINQ to SQL or trtaditional ADO.net ? what are the advantages and disadvantages of using LINQ/SQL over ADO.net? If it is ADO.net,then what is the best way to retrieve data...

Entity Framework VS LINQ to SQL VS ADO.NET with stored procedures?

How would you rate each of them in terms of: Performance Speed of development Neat, intuitive, maintainable code Flexibility Overall I like my SQL and so have always been a die-hard fan of ADO.NET and stored procedures but I recently had a play with Linq to SQL and was blown away by how quickly I was writing out my DataAccess layer a...

How Many .NET DataSources should I have?

I'm fairly new to database programming in .NET. If I want to call several existing queries from the same database for different tasks, should I have one DataSource per database, per database connection, or per query? ...

detect last record in ADO.Recordset?

If I am looping through an ADO.Recordset (with while not recordSet.EOF), is there a way to detect that I'm on the last record? ...

Can't get a SQL command to recognise the params added

Hi, I've not used basic SQL commands for a while and I'm trying to pass a param to a sproc and the run it. However when I run the code I get a "Not Supplied" error. Code: SqlConnection conn1 = new SqlConnection(DAL.getConnectionStr()); SqlCommand cmd1 = new SqlCommand("SProc_Item_GetByID", conn1); cmd1.Parameters.Add(new SqlParameter(...

SQLiteDataAdapter Fill exception

I'm trying to use the OleDb CSV parser to load some data from a CSV file and insert it into a SQLite database, but I get an exception with the OleDbAdapter.Fill method and it's frustrating: An unhandled exception of type 'System.Data.ConstraintException' occurred in System.Data.dll Additional information: Failed to enable ...

SQLiteDataAdapter Update method returning 0

I loaded 83 rows from my CSV file, but when I try to update the SQLite database I get 0 rows... I can't figure out what I'm doing wrong. The program outputs: Num rows loaded is 83 Num rows updated is 0 The source code is: public void InsertData(String csvFileName, String tableName) { String dir = Path.GetDirectoryName(csvFil...

SQL Server 2005: Invalid object name exception

In VS2005, I am using a DLL which accesses a SQL Server. The DLL returns a SQLException Invalid object name 'tableXYZ' but tableXYZ is a table in the database. Should it be looking for dbo.tableXYZ instead? Is this a permissions issue with the login being used? ...

DataReader, DataAdapter & DataSet - When to use?

I want to know when i have to use these ADO.NET Components???can anyone brief it with an example??? ...

SQL Server Collation / ADO.NET DataTable.Locale with different languages

Hi all, we have WinForms app which stores data in SQL Server (2000, we are working on porting it in 2008) through ADO.NET (1.1, working on porting to 4.0). Everything works fine if I read data previsouly written in Western-European locale (E.g.: "test", "test ù"), but now we have to be able to mix Western and non-Western alphabets as we...

An expression of non-boolean type specified in a context where a condition is expected, near 'Id',in SQL Server2005

Hi All, I am new to ADO.net and SQL Server 2005. I created one table TABLE1 with id(pk),name,group and I am trying to update using UPDATE TABLE1 SET name="stack" where id=2 then it giving bellow error An expression of non-boolean type specified in a context where a condition is expected, near 'Id'. ...

Connection Pooling

I have the following code, If I use conn == null in finally do I still use connection pooling? I know it is a good practice to close your connection but how about disposing the whole connection object? public void ExecuteNonQuery(SqlCommand Cmd) { //========== Connection ==========// SqlConnection Conn = new Sql...