ado.net

Writing to a blank excel sheet with ADO.NET

I am trying to use ADO.NET to connect to and write to an excel file. I have created a blank file with the default excel sheets (I have also tried with a custom sheet.) For some reason I am unable to write a full row of data to the sheet. If I create a new sheet it works fine, however then I have too many sheets and I am unable to delete...

Why does this code cause an error?

I have been looking for hours on how to connect to my local SQL database. I can't believe its been this difficult. Anyway, i think I am more on the right track with this code. <% Dim myConnection as System.Data.SqlClient.SqlConnection Dim myCommand as System.Data.SqlClient.SqlCommand myConnection = New System.Data.SqlClient...

What do I need to reference here?

I write this piece of code with C# using ADO.NET Entity Framework. I found error in here var departmentQuery = from d in schoolContext.Departments.Include("courses") orderby d.Name // here select d; Error message is like the following: Cannot convert lambda expression to ty...

Adding custom navigation properties using SPs in .NET Entity Framework 4

My company uses stored procs for all SELECT operations so it's making it rather difficult for me to create sensible navigation properties. I'm not too concerned at this point whether they're lazy loaded or not. So for example I created an entity for Customer then created a FunctionImport to map GetAllCustomersSP to return a collection o...

ADO.NET for connecting Oracle Database on server

Hi, Recently we have developed an application which connects to oracle database for fetching records. For fetching records, we are using OLEDB for Oracle. Application runs fine on my machine by connectng properly with Oracle ,since i have oracle client installed on my machine. Now i tried to test application on another machine, which do...

Entity Framework 4 selective lazy loading properties

Is it possible to load an entity excluding some properties? One of this entity's properties is expensive to select. I would like to lazy load this property. Is that possible? ...

Navigating a many-to-many Tables relationship in a Dataset (Optimization)

Hello, I have a Dataset that contains tables from a university database, two(actually more) of these tables contain a many to many relationship, specifically I have a, Students table (Contains information about students) Courses table (Contains information about the courses) TakesCourses table (Which is an intermediary table between th...

C# SQL query exception

I'm using C# in .NET 2.0 and I'm trying to access and manipulate a database. I can read as many times from the DB as I want and everything works, but as soon as I try to insert an item I get the following error message: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed. I've tried to l...

relation-table in dataset always returns 0 rows

I have created a strongly typed dataset in the VS 2005 Dataset Designer. There are two tables that relates to each other in a one to many relationship: Claim and ClaimDetail. The designer automatically creates a function GetClaimDetailRows which returns all ClaimDetailRows for a ClaimRow. Why is this Array's length always 0? Because Cl...

OracleCommandBuilder.GetInsertCommand() and Oracle and setting sequence.nextVal result to variable

Hello, I want to use OracleCommandBuilder to automatically generate commands for my DataAdapter. But how can I use the oracles sequences to insert values in those automatically generated commands? Yes, I know about such construction: "INSERT INTO myTable (id, my_name, my_date) ...

Can't read from my Excel file using C#

I have an Excel 2007 file "my.xlsx" and a sheet named "States", and I have the following code using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\my.xlsx;Extended Properties='Excel 12.0 Xml;HDR=NO'")) { OleDbCommand cmd = new OleDbCommand("select * from [States]", con)...

Asynchronous call of a SQL Server stored procedure in C#

Is it possible to call a SQL Server stored procedure asynchronously via C#? I have a stored procedure which writes a backup of a specific database (this can takes a longer time) and I want to show the progress of the backup process in a windows forms (for this I use http://www.wisesoft.co.uk/articles/tsql_backup_restore_progress.aspx)....

Concat Columns with NULL-values

I want to concat two Columns in the TableAdapter Wizard of the VS Dataset-Designer. The problem is that one column has NULL-Values and hence the concatination results in NULL regardless of the value of the other column. I've found out that i must SET CONCAT_NULL_YIELDS_NULL OFF, which is a Database option. How can i change this setting ...

how to get distinct records in datatable?

Hello everyone, I am using C# + VSTS 2008 + .Net + ASP.Net + IIS 7.0 + ADO.Net + SQL Server 2008. I have a ADO.Net datatable object, and I want to filter out duplicate/similar records (in my specific rule to judge whether records are duplicate/similar -- if record/row has the same value for a string column, I will treat them as duplicat...

Problem while reading excel file in C# with ADO.Net

Hello everyone, I just started C# today, and i have trouble reading an excel file. Here's what i did : OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + @";Extended Properties=""Excel 12.0;HDR=YES;"""); OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet$]", conn...

Is there a fast way to get the number of rows in an Excel sheet using ADO.Net?

Is there a better way than string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<xlxsName>;Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;ReadOnly=True\""; string sql = string.Format("SELECT COUNT (*) FROM [{0}] ", worksheetName); using (OleDbConnection conn = new OleDbConnection(connectionString)) { OleDbCommand...

Opinion: best way to retrieve/list data using .net mvc

Hi all, I'm new with the MVC framework and I was wondering what you think is the ideal way to retrieve data and list it on a page. Specifically, I'm referring to data used in report type pages, not lists of movies, books, or other clear 'objects'. Most online samples seem to suggest using ADO.net Entity Data Models & LINQ which are auto...

sorting a DataSet between reading and writing to XML

The goal is to populate a dataset from XML, sort one of the DataTables, and then write out the sorted DataSet back to XML. I can't seem to sort my DataSet and have tried a few variations. It adds the data fine but does not sort. Hope someone could help to stop me pulling my hair out. DataSet dsXml = new DataSet(); dsXml.ReadXml(msXml);...

ASP.NET Conversion of DataRow[] to DataTable

How to get a DataTable from DataRow[] collection ? I tried the following conversion , but it returns null. string ProcessQuery(ref DataRow[] rows) { DataTable _tb = new DataTable(); foreach (DataRow _dr in rows) { _tb.Rows.Add(_dr); }...

Getting return value from stored procedure in ADO.NET

I know that there is another question with nearly the same title, but it doesn't answer my question. I have a stored procedure, which returns the unique identifier after insertion (@@identity). I tried it in the server explorer and it works as expected (@RETURN_VALUE = [identifier]). In my code I added a parameter called "@RETURN_VALUE",...