ado.net

Import unique records from datatable to sql table

Hi, I have a datatable matching the structure of a MS Sql table and I would like to import new records from the datatable into SQL. So, in the example below, I am looking to import the record for Jim. DataTable: Name DOB Country Brian 11-11-78 USA Dave 01-01-80 UK Jim 02-02-81 FR SQL: Name DOB Country...

Can I use Entity Framework for this?

Hi, I am working on a application which I want to expose to external world using ODATA. Let me first give you idea of that application. In that application I need to create a library that will allow the users to perform CRUD operations on the database. For this client has provided XSD , from which we need to generate the classes. Using...

where are C# ADO.NET DbConnection.GetSchema "attributes" defined?

I find this whole GetSchema thing awfully complex. Is there any decent documentation for all this at all? One would expect that normal use is to get data for table: indexes and columns(name, type, allownulls) and then have method(s) to ask these properties. One might also expect that these properties would be enum or even a webpage that ...

SQlDataReader does not update its resultset

Hi, I have a sqldatareader populated with this command: string cmdlookup = String.Format("Select {0} from {1}", strSourceName, strSourceTable); SqlCommand sqlcom = new SqlCommand(cmdlookup, con); SqlDataReader rdrsource = cmd.ExecuteReader(); while (rdrsource.Read()) { this.lstSourceValues....

What data type does the SQLCommand method ExecuteScalar() return?

In SQL Server, ID is a not null integer, and an identity. When I run the following code, I get an InvalidCastException on the last line: SqlCommand cmd = new SqlCommand(); cmd.Connection = _conn; cmd.CommandText = @"INSERT INTO [Users] (Name, Email, Password) VALUES (@name, @email, @pass); SELECT SCOPE_IDENTITY()"; cmd.Parameters.Add...

inserted writes

code : SqlConnection sqlc = new SqlConnection( "Data Source=" + Environment.MachineName + @"\SQLEXPRESS;" + "Integrated security=true;" + "database=someDB"); SqlCommand sqlcmd; string tmp = string.Empty; for(int i = 0; i < 100000; i++) { tmp += "inserto into [...

How to define and add a enum as type

I am working on custom data provider using ADO .NET Entity Framework. In the CreateMetaData function, I need to add primitive and complex properties in the ResourceType. I believe Enum should be added as the complex data type. If yes, how can I add this? Any pointer would be a great help. Thanks, Ram ...

Multiple different Excel sheets into one SQL table

Hello, I have a lot of excel sheets which columns are slightly different, i want to import all of these sheets (one at a time) into ONE SQL TABLE. I'll give an example : Say ive written the required program and called it Excel2sql converter. So Excel2sql takes an excel sheet and create a database table with the data of that excel shee...

Entity Framework vs Linq to Entities vs Linq to SQL

Hi I read a lot articles about how to work with database in WPF .Net 4 application. As I understood, the main two technologies are: Linq to SQL (L2S) Entity Framework (EF) but sometimes I also can see mention of Linq to Entities (L2E) technology, but can't find clear explanation what difference between EF and L2E. So, my question i...

Calling Oracle package procedures which return ref cursors in straight PL/SQL

I've got an Oracle 10g database which is accessed from an ASP.NET application. Although I've used SQL Server heavily in many different aspects and Oracle for querying and reporting, this is my first time using Oracle as the OLTP database for an application. The database-level procedures in the packages are typically of the form: -- TY...

WPF TextBox won't update source

I'm trying to make a simple form that contains textboxes that draw from a db in my project. I'm using the table adapter's GetData() method in the xsd file to populate the data context. I want to update one of these textboxes and have the changes reflected in the database. The textboxes populate fine, but the changes don't make it back to...

ADO: Execute multiple TSQL using connection and command object

For a particular installation of my application, I need to create the database and the schema on the SQL server from the installer itself. I have a custom installer through which I have been able to detect and install the pre-requisites and the software. The user is prompted to give the IP of the database server and the username and pass...

Problem reading excel sheet

SqlDataReader reader; string r=""; if ((FileUpload1.PostedFile != null)&&(FileUpload1.PostedFile.ContentLength > 0)) { r = System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName); } OleDbConnection oconn = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data Source="+r+";" + @"Extended Properties=""E...

Best way to access a SQL Server database using C# .Net

Hello, I am new to .NET and have heard about several different ways of querying a SQL Server databse such as ADO.NET and the entity framework. Can anyone give me some advise about the best way to go for new applications? Thanks for any help or suggestions. ...

.NET ODBC Oracle Params getting param name returned by db provider- possible?

I'm converting some RDO code to ODBC Provider code in .NET. The problem is parameter names were not specified in the orignal code, but param values were retrieved by parameter name after the command was executed. Is there anyway to have parameter names populated by the provider once the command is executed so calling code can access pa...

How to read an .XLSX (Excel 2007) file using ADO.NET? I am finding "Could not find installable ISAM"-error.

I need to work in .net 2.0. So I can't use OpenXML. This is my source code and I have already Installed AccessDatabaseEngine.exe. But still getting the exception: "Could not find installable ISAM". I have also tried "Extended Properties=Excel 8.0" in the connection string. static void Main(string[] args) { DataSet dataSet = new D...

Entity Framework POCO and Self Tracking entities

Hello I wonder what's the difference between standard EF objects, POCO and Self Tracking Entities. I was looking the web but couldn't find a valuable introduction. Any help would be appreciated. ...

How to execute an ALTER TABLE query?

I have an SQL table called tbl, im trying to add the columns A, B and C to it. When i execute the command : String addcolumns = "ALTER TABLE SqlCreatedTbl ADD A char(50) ;"; ...... cmd = new SqlCommand(addcolumns, conn); conn.Open(); cmd.ExecuteNonQuery(); The column i...

Why both SqlConnection and SqlTransaction are present in SqlCommand constructor?

I wonder, what is the reason to have this SqlCommand constructor overload: public SqlCommand( string cmdText, SqlConnection connection, SqlTransaction transaction ) ? When I need to create an internal method that does its bit using a transaction provided as an argument, I always find it sufficient to only pass an SqlTrans...

How to update using DataSet (C# and MySQL) with the database with no primary key

I am working on windows application using c# and MySQL. I inserted new record by reading text file into MySQL database, Database having no primary key but combination of four columns we can consider as component of primary key (but actually database having no primary key). I know how to add and update record using DataAdapter and DataSet...