ado.net

What is use of Command Builder in ASP.NET ?

Command builder builds Parameter Object. What does it mean by parameter object? Why are they created ? Why does Derive Parameter method need extra round trip to Data store ? ...

Getting around the lack of a Left Trim(string, char[]) function in JET / Access

I need to remove leading zeros from a string field in an Access database that is destroyed and recreated every time it is used within a C# program. Most string libraries (even SQL ones) include a Trim function to remove leading or following whitespace. Unfortunately, Access does not seem to have a LTrim(string s, char[] trimChars) or som...

Optimal way to handle .dbf from C#

What data-provider can I use to update .dbf file from C#? I tried a few different .dbf providers to create a DataSource but I get a message like this: "Error Message: ERROR HYC00 Microsoft ODBC dBase Driver Optional feature not implemented." Or when I generated a dataset and a dataadapter with an update function I got: "Update requires...

How to add a row to databound combobox?

I have a combobox and I need the first row to be set as default. This is my code cbBrandForModel.DisplayMember = "BrandName"; cbBrandForModel.ValueMember = "BrandID"; cbBrandForModel.DataSource = dataTable; I need to add this: cbBrandForModel.DisplayMember = "Select Brand"; cbBrandForModel.ValueMember = "0"; Can anyone tell me...

Identity column in a table-valued parameter in procedure, how to define DataTable...

Is it possible to pass a parameter of type "table" with a column of type "[int] IDENTITY(1,1)" to a procedure and execute this stored procedure with a DataTable object passed as the input parameter? I get the following error: "INSERT into an identity column not allowed on table variables. The data for table-valued parameter \"@xxxxx\" d...

With DataSet create SQL Server dynamic tables with populating data

I have a DataSet with multiple tables (distinct schema). I want to generate table schema on SQL Server 2005 and insert data into the dynamically created table. Table name should be the name of DataTable (which is unique i.e. data0, data1, ...) Is there a way to insert it in to the SQL Server database without going through DataTable ro...

Reading an Access Query from Visual Studio 2010 (VB.NET)

I have a database in access and one of the fields is 'Is Quick'. I have a query that filters all of these out. How would I get the data from that query in Visual Studio 2010 (Express). VB code please. ...

Update doesn't work in ADO.net Entity Data model

Hi everyone, I use ADO.net Entity Data model for work with database. In my program, I want to update a record of user table, so I use the code below to do this. In this function I send changed user info and then overwrite the information with the current user information. After I run objUser = _user; and then call objContext.SaveCha...

Write xml cofiguration file and C# parser for ado.net query .

I wont to write a xml configuration file that containg query to the same db, only query to view. The "query node" must have the filters parameter. How i can write this xml file and the C# Parser , and QueryBuilder classes. I wont some thinl like this: <Query Name="Application Approval by Month" src="APPLICATION_APPROVAL_COUNT_BY_MONT...

Problem with cmd.ExecuteNonQuery()

Hi All, I am inserting values in to Database from a Webform using ADO.NET, C#. DB I am using is Oracle Database. Values are not being inserted and the program gets struck at the cmd.ExecuteNonquery() Here is my Code below, Please let me know If I am doing any mistake.. I am using some Static Methods will that be any problem ?.. publ...

ADO.NET: Does ExecuteScalar close the connection automatically?

Does ExecuteScalar close the connection automatically? ...

Comparing two rows for the same table multiple times

I have a SQLServer table that contains snapshot data. I need to compare the latest row against the previous and determine if certain columns have changed. I need to do this several times comparing different combinations of columns, up to 40 at a time. Every time a column value differs within one of the combinations I need to create an xm...

Correct C# conversion counterpart for VB's CTYPE()

The below is a snippet from VB that I am porting to a C# rewrite. My question is what is receipt_date after the assignment? Is it still an object or is it a string? Dim receipt_date As Object receipt_date = CType(dr.Item("RECTDT"), String) Would this be the correct C# counterpart? object receipt_date; receipt_date = dr["RECTDT"].To...

Object reference not set to an instance of an object Caused by DBNull.Value

SqlCommand objsql = new SqlCommand(); . . objsql.Parameters.AddWithValue("@Param1", DBNull.Value); . . . I get an exceptional error: "Object reference not set to an instance of an object" If i do: objsql.Parameters.AddWithValue("@PaymentMethodID", null); I get the following error: The parameterized query '(@SupplierQuoteID int,@Pa...

Create a adapter without knowing the driver type

One of the great things with ADO.net is that you dont have to know which kind of connections/commands that you are using (interface based programming). You can use a connection to create a command, and command to create a reader. IDbConnectin con = CreateConnection(_connectionString); //factory method IDbCommand cmd = con.CreateCommand...

Couldn't connect to sql server database from ado.net.

Hi there! I wrote simple sql script that creates my database: create database [MaterialStream]; exec sp_addlogin N'MaterialStreamLogin', N'123', N'MaterialStream' exec sp_adduser N'MaterialStreamLogin', N'MaterialStreamUser', N'db_owner' And then couldn't connect to my database from ADO.NET. How can I set up credentials for my user? ...

How do I Add an Event Handler To the RowUpdated event in a table adapter

I have a tableadapter and I want to do something when the RowUpdated event is fired. I can't figure out where to put the code to add the handler to the event. public partial class MyTableAdapter { void OnRowUpdated(object sender, System.Data.Odbc.OdbcRowUpdatedEventArgs e) { } } How do I get the code below to run when the TableA...

How do I register a DbProvideFactory?

I am trying to create a new ADO.NET connection string using the 'Add Connection' dialog. I click the 'Change' button to change the selected 'Data Source' but can't see the desired data source in the list of registered data sources. Now, I know I need to update the machine.config file 'DbProviderFactories' element with the appropriate e...

Why do I get ORA-24784: Transaction exists? Standard code snippet, C#, ADO.NET, OracleClient.

I am a beginner in this area, but the code I write is right out of my textbook (Professional C# 2008, from Wrox). The example in the textbook is about Microsoft SQL Server, so the problem is most likely related to the fact that I work against an Oracle database, using System.Data.OracleClient: OracleConnection conn = GetDatabas...

SqlCeResultSet doesn't reflect changes if starting with empty database

I have an application with multiple SqlCeResultSets, and a combobox and a datagrid on one form. I have setup the ResultSets to return subsets of the same SQL CE table, using statements like: "SELECT * FROM DLH WHERE STATUS = 'A'" "SELECT * FROM DLH WHERE STATUS = 'D'" "SELECT * FROM DLH" Which return ResultSets named DLH_A, DLH_D and ...