ado.net

Unable to cast object of type 'System.Data.DataTable' to type 'System.Data.DataView'.

I need help every time i run this code i get the same error Unable to cast object of type 'System.Data.DataTable' to type 'System.Data.DataView'. the code is Dim plmExcelCon As New System.Data.OleDb.OleDbConnection Dim cmdLoadExcel As System.Data.OleDb.OleDbDataAdapter Dim PrmPathExcelFile As String PrmPathExcelFile =...

Does DataReader.NextResult retrieves the result is always the same order

I have a SELECT query that yields multiple results and do not have any ORDER BY clause. If I execute this query multiple times and then iterate through results using DataReader.NextResult(), would I be guaranteed to get the results in the same order? For e.g. if I execute the following query that return 199 rows: SELECT * FROM product...

Can ASP.NET MVCF be used with a Postgresql database?

I was wondering if ASP.NET MVCF be used with a Postgresql database? ...

ADO.Net vs Bound Controls

Is there any compromise regarding resources, if I use bound controls on my asp.net app versus ado.net? When is it best to use bound controls and when is it best to use ado.net to connect to database? Thanks ...

typed dataset for populating custom objects ?

I'm about to develop databse server app; I have decided not to use typed dataset/dataset, except in the DAL, (so I'm not asking the question whether to use dataset or custom objects). Populating my custom objects with data requiers an interaction with DataSet in the DAL. I have seen a reasonable way of using typed dataset for this purp...

Using .NET Entity Framework in Medium Trust Enviroment like Mosso/Rackspace Cloud Hosting

I have an application that is using .net's Entity Framework. This application runs fine on my local machine and my local server. However, trying to run the app on mosso which runs in medium trust returns an error. I am not sure how to appropriately use entity framework in medium trust. I have the entity model in a separate project ...

How to make relation between tables which are in same dataset?

I have one dataset in which there are 40 tables. Now i want to make a relation between these tables and show important data in grid. How do i do this? ...

How does ADO.NET store dates and time?

I was lazy and write an insert statement with DateTime.Now. It occur to me later i should have written DateTime.Now.ToUniversalTime(). This got me thinking, does ADO automatically convert dates into universal time? and restore it to local when i pull data out? Or do i need a write ToUniversalTime and ToLocalTime myself in every area of c...

Readonly connections with ADO.NET, SQLite and TSQL

My code reads via one connection and writes via another. I dont want to accidentally write with the read connection. How can i make the connection readonly? I am using SQLite ATM and will convert sections of code to tsql when the prototype is over. ...

what is the best way to learn the database connectivity in .net

I like to learn about database connectivity in .net, Where i will start for that ...

MS Access/ADO AddNew method not appending record

Hi, I'm using ADO 2.1 in MS Access 2003 and calling the AddNew method of an ADO recordset using an array of field names and an array of values. I am getting no error messages however, the record is not being written to the table. I have tried following the command with a .Update and a .Requery to no avail. Any ideas? Public Function ...

Using NHibernate transaction in SqlBulkCopy

I'm storing some data using NHibernate, and I need to insert huge amount of data as a part of this action - i.e. in the same transaction. Code looks like this: using (ISession session = NHibernateHelper.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.SaveOrUpdate(something); // ... Sq...

Missing "ADODB" assembly with Mono?

Hello, I'm trying to port some ASP.Net code to mono. I am testing it using xsp2. I compile it with Visual Studio also before running it with xsp2. Whenever I go to a practically blank page in my application I get Parser Error Message: Assembly ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A not found I ha...

How to check if i am in a transaction?

I have a piece of code i recently expanded but now must use a transaction. It looks like it can only be access while in a transaction but looks like doesnt make me feel comfortable. Using SQLite and ADO.NET i wrote if(cmd.Transaction==null) but it is null and in a transaction. How should i check? NOTE: I will be using this code with TSQ...

How do reduce transaction log growth for batched nvarchar(max) updates

Our app needs to add large amounts of text to SQL Server 2005 database (up to 1 GB for a single record). For performance reasons, this is done in chunks, by making a stored procedure call for each chunk (say, usp_AddChunk). usp_AddChunk does not have any explicit transactions. What I'm seeing is that reducing the chunk size from 100MB t...

Overriding rows affected in SQL Server using ExecuteNonQuery?

I have an insert statement that pulls some data into a few table variables and then based on that data does a few inserts into several tables. I only care about the rows that are inserted into the real tables and not the table variables, but ExecuteNonQuery will return the sum of all @@ROWCOUNT's. What I would like to know is there a way...

Using a xml column with ADO.NET Entity Framework

In .NET 3.5sp1, I have a table in Sql Server that is defined somehow like this: CREATE TABLE Employee( EmployeeId [int] IDENTITY(1,1) NOT NULL, UserName varchar(128) NOT NULL, [Name] nvarchar(200) NOT NULL, Address xml NULL, ...) I am mapping this table to the ADO.NET Entity Framework. My problem is that the xml column is map...

Insert records into a database from a hashtable

Hi All, I'm looking for any advice on what's the optimum way of inserting a large number of records into a database (SQL2000 onwards) based upon a collection of objects. Currently my code looks something similar to the snippet below and each record is inserted using a single sql simple INSERT command (opening and closing the database...

Does ADO Entity Framework support non DTC transactions? Multiple queries inside one EntityContext and one TransactionScope is causing DTC promotion

I have a web application that uses the Entity Framework - we make use of the TransactionScope class to provide ambient transactions. Is there any way to tell EF to use a standard T-SQL transaction in preference to DTC transaction? Quite often we make a number of queries to different tables inside one EntityContext and one TransactionSc...

How to show value printed by sql query in message box

I want to print a value that is returned by sql server. If NOT Exists(SELECT * FROM ItemList WHERE ItemName='txtItemNama') BEGIN INSERT INTO ItemList (ItemName) VALUES('txtItemNamea') END ELSE BEGIN Print 'Duplicate' END This query will either return me either no of rows effected or Duplicate I want to ...