ado.net

How can I request the database product name with ADO.NET?

I develop a product with a custom database configuration. I use ADO.NET with System.Data.Odbc.OdbcConnection for it. To make some differences between the databases is there a simple solution to detect the current DBMS of a connection. ...

Recommend a good ADO.NET book?

Any good books on ADO.NET out there? Please let me know. Thanks. ...

.NET - SQL Connection Error - Developing a Web App Locally

I have Visual Studio 2008 and SQL Server 2008 Developer Edition installed on a Windows XP machine. I get this error when trying to work on a Test Web Application: 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 instan...

Common method in datalayer for SQL/Oracle DB's..

In .NET if my DB is SQL Server then in datalayer we have statements SQLConnection, SQLCommand, SQLDataReader... Suppose we change the DB to oracle then we need to change the statements to OracleConnection, OracleCommand, OracleDataReader and so on everywhere. Instead how can I have some generic method so that at runtime based on DB typ...

LINQ to Entities and creating a new instance of an entity

I am trying to create a new instance of a Customer entity in our application, and I am having a few problems. This entity has several navigational properties, each of which has their own nav. properties. For example, each Customer entity has an Address entity, and each Address entity has a Phone Number entity etc. I haven't figured ou...

Visual Studio will not connect to Sql Server 2000

I am no longer able to graphically see tables, server or databases in Visual Studio 2008. If I open previously created datasets all I see is the XML as if I had selected view code instead of designer, I have also lost my server explorer window and when I try to re-add it from tools --> connect to server or database nothing happens. Noth...

Some data changes in the database. How can I trigger some C# code doing some work upon these changes?

Suppose I have some application A with a database. Now I want to add another application B, which should keep track of the database changes of application A. Application B should do some calculations, when data has changed. There is no direct communication between both applications. Both can only see the database. The basic problem is: ...

precision problem on decimal DbParameter

In c#, I use a decimal out DbParameter for a Sql Server stored procedure. I create parameter like that DbParameter prm = comm.CreateParameter(); prm.ParameterName = "@Price"; prm.DbType = DbType.Decimal; prm.Direction = ParameterDirection.Output; comm.Parameters.Add(prm); //and set the value of comm.Parameters["@Price"] to a var...

How to run a sp from a C# code?

Hi, I am new to ADO.net. I actually created a sample database and a sample stored procedure. I am very new to this concept. I am not sure of how to make the connection to the database from a C# windows application. Please guide me with some help or sample to do the same. ...

How do you catch exceptions with "using" in C#

Given this code: using (var conn = new SqlConnection("...")) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "..."; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { // ... } } } } I'm used to ...

How to use ADO.net Entity Framework with an existing SqlConnection?

I have an existing asp.net website that uses an SqlConnection. I have added the ADO.net Entity Framework. I have successfully connected to the database and created the .edmx file. I am able to connect through the Entity Framework with the connectionstring that is automatically generated. I want to use the existing SqlConnection object...

ADO.NET SQLServer: How to prevent closed connection from holding S-DB lock?

i Dispose an SqlConnection object, but of of course it isn't really closed. i need closed connection to not hold locks on database objects. How can i prevent closed connections from holding locks? Explanation of the above sentance for those who don't know: When you close an ADO or ADO.NET connection, you aren't actually severing the...

Can you use cmd.ExecuteScalar when the sproc uses RETURN @value

Hi, Can you use int blah = Convert.ToInt32(cmd.ExecuteScalar()); When the sproc's last statement does: RETURN @value I can only get it to work if it does: SELECT @value Also, this gives me a object null exception: int blah = (int)cmd.ExecuteScalar(); isn't convert.toint32 and (int) the same thing but one is a wrapper of the ...

Map classes to database with ado.net

Hey there, I want to know if there is way to create a database out of existing classes with the ado.net entity framework or to map existing classes to a database. I looked for tutorials and only found ways to create the classes with the entity model designer. As an example I have the class Bird with Properties Length and Age On the...

How to merge the result from database call?

I have a web report needs to return multiple products from different regions. The simplified query will be like: Select ProductName, ProductPrice from Product where Region in (Region1, Region2, Region 3) The regions are selected by users from UI. The result is bound to a datagrid. It could be multiple regions. But the result will be...

Filling tableadapter with stored procedure takes signifigantly longer than running stored procedure in SQL

I have been trying to fill my ultracombo box with data yet it takes a signifigant amount of time. However when I run the same stored procedure from withing sql server it takes relatively no time. The line of code that the program gets hung up on is: SprocPatientsTableAdapter.Fill(Me.PatientsDataSet.sprocPatients, SelectedCustomerID) B...

Extracting subset of DataSet by pulling rows, following relationships

Is there a relatively easy way to extract a relationship-consistent subset of a DataSet? The subset I want is: the rows I'm interested in, all the child and parent rows required by those rows, and nothing else. I have around a dozen tables, each with two to four relationships to other tables. I figure I could write code to traverse ...

How can I enforce the use of factory methods on a strongly typed DataSet?

Without breaking the VS2008 designer, can I set my DataTable.New*Row methods internal while leaving the overall DataSet and its tables and classes public? I'm using the VS2008 designer to create an ADO.NET strongly typed DataSet for my application. Some columns refer to external tables. I'd like to check those references at creation ti...

How do I prevent DataRow cell values from being reset?

We're creating a demonstration mode for our web application. We're going about this by creating new user that is tied to a real client, showing all of their data, but filtering certain fields to be non-identifiable (names, important numbers, etc...) The weird part here is that the data is correctly filtered for standard "show one" page...

How to find the table names from a schema through Ado.net without using stored procedure etc?

I am trying to read data from excel files using datatable. The command "select * from [Sheet1$]" works fine but if the excel file has sheet with different name it gives error. So now I need know how can I find the table names available in a schema using ADO.Net. ...