ado.net

my code reading Excel file error

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 to read Excel file created by Excel 2007 (but saved as Excel 2003 xls format). Here is my code, when executing code adapter.Fill(cities), there is exception -- "OldDbException Could not find installable ISAM". Any ideas what is wrong? static void Main(string[] args) { string conn...

How can I make a function that can take a SQLDataReader and a DBDataRecord as a parameter?

I have a function that is normally called while looping inside a SqlDataReader, that will take data from that SqlDataReader and do some stuff with it. Now, I need to be able to also call it from inside a Data Bound Repeater object, that is also bound to a SqlDataReader... In the DataBound control, in the "OnDataBinding" event, I normal...

Should I create a ADO.NET Entity Data Model for each table, or one for my entire database?

Hi, Are you supposed to use one ADO.NET Entity Data Model for each table? Or one for your entire database where relationships are also routed, etc... ...

How I can Update the row ionto database using ADo.net Data Entity Model

How I can Update the row ionto database using ADo.net Data Entity Model ...

Entity Framework references not loading automatically

In the ADO.Net Entity Framework, I have an object which has 4 references to other objects. For some reason, when I query those references, two of them load automatically (as expected), and two of them always return null. Bizarrely enough, when I manually ask the references to load, they load just dandy. As an example: if (account.Hold...

.NET: How to change the value in a DataTable

In ADO.NET i'm using GetSchemaTable to return the schema table for a results set. DataTable schema = rdr.GetSchemaTable(); gridSchema.DataSource = schema; gridSchema.DataBind(); Unfortunatly the "ProviderType" value is displaying as an integer, rather than the OleDbType enumeration value that it is: ProviderType Desired Display ...

Alternate to SqlTransaction exposing Events - C# ?

Hi, I want to perform some logging when a SqlTransaction is committed or rolledback. I see that SqlTransaction class does not expose any such events like OnCommit or OnRollback. damn! SqlTransaction class is sealed, I cant help it out with inheritance. Now, what must be the reason they have not allowed these events to happen ? Is th...

Why would I get this error intermittently? "The server was not found or was not accessible"

We keep getting this error randomly in our web application. System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured t...

Help with adding checkbox column to DataGridView in window form

Hi I am trying to add a checkbox column to a DataGridView in a simple window forms application. I am pulling back some data from a database using ADO.NET, putting into a datatable, and then setting the datagridview datasource to the datatable. I then want to add a checkbox column as the second column. So far I have this code that seems...

Database access in GUI thread , bad isn't it ?

I'm working through some MSDN examples, and some books on ADO.Net. What they all have in common is using the point/click/drag-drop design time feature in Visual Studio to develop database applications, binding data sets to controls etc. And the resulting code does all DB access in the GUI thread, as far as I can tell. This sounds like b...

Connection timeout when trying to open a connection.

I'm getting this error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. I know that most of the time this problem is fixed by adding the commandtimeout property of a sqlcommand. The problem is that I'm getting this error trying to do this: Dim con as new SqlConnection...

Better way to iterate over strongly typed rows from DataView ?

Using dotnet 2.0. I currently have code like this : DataView dv = new DataView(dsTrans.Transactions, filterSpec, sortSpec, DataViewRowState.CurrentRows); foreach (DataRowView dvr in dv) { DSTransactions.TransactionsRow transRow = (DSTransactions.TransactionsRow)dvr.Row; // do something with transRow } where "dsTrans" is...

updating data in EXCEL using ado.net , how to refer to columns in sql statement ?

I am connecting to the excel file using ADO.NET OLeDB drivers. In the connection string I have HDR=NO ( which means my excel file does not have header) I want to run update statement and refer to column as they are in excel file. The below sql query throws the following error : No value given for one or more required parameters. update...

Something about my ADO.Net Entity Data Model is causing it to give my app an Internal Server Error...

I was trying to use ajax to retrieve data from a repository using a controller and I kept getting Internal Server Errors... I've whittled it down to the line: private MyDBEntities _myDB = new MyDBEntities(); That's located in the repository, without that line I don't get the Internal Server Error. The line is called after the Reposito...

SQL Scripts from dotnet with transactions

I have been trying to execute sql scripts from dotnet (C#) but the sql scripts could contain GO statements and I would like to be able to wrap the collection of scripts in a transaction. I found this question and the accepted answer got me going for handling the GO statements, but if I use a BeginTransaction it throws a InvalidOperation...

Is there an implementation of IQueryable over DbDataReader?

I have a lot of existing code which uses raw ADO.NET (DbConnection, DbDataReader, etc). I would like to transition to using LINQ to SQL for new code, but for now put both the existing and new code behind a unified set of Repository classes. One issue I have is this: I would like the Repository classes to expose result sets as IQueryab...

How to create a DataTable in c# and how to add rows?

Hi Can any body plz help me creating DataTable in c#. I did like this DataTable dt=new DataTable(); dt.clear(); dt.Columns.Add("Name"); dt.Colums.Add("Marks"); and how to see the structure of DataTable. Now i want to add for name : ravi and Marks : 500 how to do this one Any Help will greatly Appreciated ...

How to retrieve scalar value from stored procedure (ADO.NET)

Hello everyone, If in the stored procedure, I just execute one statement, select count(*) from sometable, then from client side (I am using C# ADO.Net SqlCommand to invoke the stored procedure), how could I retrieve the count(*) value? I am using SQL Server 2008. I am confused because count(*) is not used as a return value parameter of...

Using IsolationLevel.Snapshot but DB is still locking.

I'm part of a team building an ADO.NET based web-site. We sometimes have several developers and an automated testing tool working simultaneously a development copy of the database. We use snapshot isolation level, which, to the best of my knowledge, uses optimistic concurrency: rather than locking, it hopes for the best and throws an ...

How to check stored procedure return value elegantly

Hello everyone, Here is my current implementation of a stored procedure which returns Order status for a given Order ID. There are two situations, there is matched Order ID and I will retrieve the related status, there is no matched Order ID (i.e. non-existing Order ID). My confusion is, how to implement the two functions elegantl...