ado.net

What is an Ado.net equivalent of this Ado sample?

AFAIK ado.net datareaders and datasets don't seem to support joins in sql statements. Is it possible to retrieve the ado.net equivalent of this ado recordset using just the information presented in this ado/vb code : I am asking the question this way as I am trying to largely automate the conversion of ado to ado.net Dim myconn As...

How Do The Entity Framework 2 And NHibernate Compare?

I would basically like to know things such as: Advantages/disadvantages between the two? Similarities/differences between the two frameworks? How are they similar/different architecturally? How much boilerplate code is needed to use each? Can the Entity Framework be used efficiently outside of Visual Studio compared to NHibernate? Is t...

What does Trusted = yes/no mean in Sql connection string?

What does Trusted = yes/no mean in Sql connection string? I am creating a connection string as below : string con= string.Format( "user id=admin;password=admin;server={0};Trusted_Connection=yes;database=dbtest;connection timeout=600", _sqlServer); Please Help ...

Grid View Pagination.

Dear All, I have a grid view and I want to implement Pagination functionality.This is working fine. protected DataSet FillDataSet() { string source = "Database=GridTest;Server=Localhost;Trusted_Connection=yes"; con = new SqlConnection(source); cmd = new SqlCommand("proc_mygrid", con); ds = new DataSet(); da = new Sq...

.NET Dataset vs Business Object : why the debate why not combine the two ?

I read there is a debate here http://blogs.objectsharp.com/cs/blogs/barry/archive/2004/02/10/273.aspx Why the debate ? Dataset for me is like relational database, Object is a hierarchical-like model, why do people absolutly want "pure" Object model whereas we still deal with relational database so why not combine the two ? And if yes i...

Sorting in gridview is not working

Dear All, I am trying Sorting functionality in Grid view but its not working.Can some body help? Code: private string ConvertSortDirectionToSql(SortDirection sortDirection) { string newSortDirection = String.Empty; switch (sortDirection) { case SortDirection.Ascending: newSortDirection = "ASC"; ...

Where should I create my DbCommand instances?

I seemingly have two choices: Make my class implement IDisposable. Create my DbCommand instances as private readonly fields, and in the constructor, add the parameters that they use. Whenever I want to write to the database, bind to these parameters (reusing the same command instances), set the Connection and Transaction properties, th...

Missing ADO.NET Entity Data Model

When I'm in Visual Studio 2008 with an ASP.NET MVC project running, I can't seem to add an ADO.NET Entity Data Model to my project, it doesn't show up in the list of available things to add under the "Data" category. I've made sure I'm running VS2008 SP1 and have .NET 3.5 SP1 installed. Am I missing anything? Other thoughts? Thanks s...

How to implement sorting functionality in gridview?

Hi All, I am trying to implement sorting functionality in grid view but its not working.. Code: //enter code here public partial class _Default : System.Web.UI.Page { SqlConnection con; SqlCommand cmd; DataSet ds; SqlDataAdapter da; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["myDa...

Is there a way to get the full sql text back from SqlCommand after param substitution?

I created a SqlCommand with an SQL query containing parameters. I than add all the parameters to the class. Is there an easy way to see the resulting SQL query before it is sent off to the db? This would be handy for debugging purposes. (e.g. copying the entire query and run it in the management studio to try and pinpoint problems) R ...

My Query class. Your opinion?

I just wanted to share this Query class and get your thoughts on it. The Query class helps execute queries against a dbconnection. I haven't included the implementation, it's a bit much to post. Here's an example call, you'll get the idea: OrdersDataTable table = new Query(connection) .Table("Orders") .Fields("OrderID,Customer...

very strange string unique issue in C#

Hello everyone, I am using VSTS2008 + C# + .Net 3.0. Here is my code and related exception from ADO.Net. Here is my input two strings in both binary form and text form, any ideas what is wrong? Why the two different strings will be treated as the same by ADO.Net? Exception message: An unhandled exception of type 'System.Data.Constrain...

How to return single sql result in a string without using datatable (C#) ?

I know how to fill a datatable with dAdapter.Fill(dTable) using System.Data.OleDb But it's heavy if I just want to retrieve a single string value like "select name from table where idperson = 1" Can't I bypass creating a DataTable ? I want to create an equivalent of dlookup function in MS Access. ...

IDbTransaction Rollback Timeout

I am dealing with an interesting situation where I perform many database updates in a single transaction. If these updates fail for any reason, the transaction is rolled-back. IDbTransaction transaction try { transaction = connection.BeginTransaction(); // do lots of updates (where at least one fails) transaction.Commit();...

Faster (more scalable) DataSet.Merge?

We use strongly typed DataSets in our application. When importing data we use the convenient DataSet.Merge() operation to copy DataRows from one DataSet to another. StringCollection lines = ReadFromFile(fileName); foreach (string line in lines) { DataRow dr = ImportRow(line); dataSet1.Merge( new DataRow[] { dr } ); } DoAdditiona...

Sharepoint List to ADO.Net data table

Is it possible to convert a share point list (getting it via the web service or object model) and transform it into a ADO.NET data table? ...

Deleting an entity that has an un-loaded child entity

I need some clarification re cascade deletes in Entity Framework and despite searching for hours am no closer to a solution. In a nutshell, if I have an entity (MyObject) that has a 1->0..1 relationship with a child (MyObjectDetail) then I can't delete MyObject without an UpdateException complaining about constraints - but ONLY IF the ...

MysqlCommand switching connection unexpectedtly

I have a little problem with my MysqlConnection objets. I have those two connection strings in my app.config : <connectionStrings> <add name="bdpvcLocalhost" connectionString="Persist Security Info=False;server=localhost;Uid=root;Password=***;database=bdpvc" providerName="Mysql.Data.MySqlClient"/> <add name="bdpvcProduction" c...

Refactoring ADO.NET - SqlTransaction vs. TransactionScope

I have "inherited" a little C# method that creates an ADO.NET SqlCommand object and loops over a list of items to be saved to the database (SQL Server 2005). Right now, the traditional SqlConnection/SqlCommand approach is used, and to make sure everything works, the two steps (delete old entries, then insert new ones) are wrapped into a...

Do I Still Need To Install Oracle Client if Using Microsoft ODBC for Oracle to connect to an Oracle Database?

Using ActiveX Data Objects 2.8 Library as a Reference from Excel VBA, and the connection string is: "Driver={Microsoft ODBC for Oracle}......." And I also have the "Microsoft ODBC for Oracle" (MSORCL32.dll) entry in the Drivers tab of Windows XP's ODBC Manager. Now, will I be able to connect to an oracle databse, without any oracle cl...