ado.net

What's the best sequence to compress binary data, encode it, and convert to string?

I'm trying to store a gzipped binary serialized object into Active Directory's "Extension Attribute", more info here. This field is a Unicode string according to it's oM syntax of 64. I'm saving the binary object into AD's Unicode format like this: byte[] bytes = ... // This is my blob System.Text.Encoding.Unicode.GetString(bytes); ...

Confusion in inserting a whole 200 records in dataTable into a database file in my code

Hello, I am a beginner in ADO.NET C# programming. My intent is to transform all records from dt (my DataTable) to a database file in Driver C (C:\datamining.mdf). However I am confused to do so, since I cannot use the known SQL Insert Statement {INSERT datatable VALUES (,,,,) } since my datatable has got 200 records. Here is my code: us...

Is there anything faster than SqlDataReader in .NET?

I need to load one column of strings from table on SqlServer into Array in memory using C#. Is there a faster way than open SqlDataReader and loop through it. Table is large and time is critical. EDIT I am trying to build .dll and use it on server for some operations on database. But it is to slow for now. If this is fastest than I have...

ADO.Net: SqlDataAdapter and get some more info without select query after update method?

Hi I use ADO.net and run an update query by sqldataadapter. The update query updates some records. My question is: Is it possible getting some more info for example IDs of affected records without a select query after running that update query? ...

Can't find ADO.NET Entity Model Browser Window in vs2010

I want to update my ADO.NET Entities Framework Model from the database, but I cannot find the Entity Model Browser Window. There is an example of how to update my model here, but I cannot find how to open the model browser. Could someone please tell me exactly how to open it using Visual Studio 2010? I tried finding it through the view ...

How to dispose of a SqlDataReader which is bound to a control

I have an SqlDataReader which I use with a data-bound control. Since I'd like to free the DB-connection as soon as it is no longer used, I'm putting the relevant code into a using-block, e.g. as suggested here: using (SqlDataReader reader = getReader()) { databoundControl.DataSource = reader; databoundControl.DataBind(); } ...

Using a tableadapter with multiple datagridviews to return different results

Can someone please help out with this particular problem, I'm trying set up 2 datagridviews on a page. Both access the same tables through the same stored procedure. My project contains a dataset which has the appropriate stored procedure in a tableadapter. The idea is that 2 datagridviews will provide results for 2 different searches...

How to fetch lots of database table records by primary key?

Using the ADO.NET MySQL Connector, what is a good way to fetch lots of records (1000+) by primary key? I have a table with just a few small columns, and a VARCHAR(128) primary key. Currently it has about 100k entries, but this will become more in the future. In the beginning, I thought I would use the SQL IN statement: SELECT * FROM `...

MSTest.exe not able to load ADO.NET Data providers?

I'm having a really strange issue with MSTest. I have a test that is more of an integration test, and needs to connect to the database. It does this by getting the ADO.NET data provider factory through a call to: var factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client"); In my app.config file, I have: <system.data> ...

SqlDbType and Geography

What SqlDbType enumeration should I use when my column is the Geography type? I'm using MS SQL Server 2008 R2. This is what I'm looking for specifically: // ADO.net - what do I use for the SqlDbType when it's defined // as Geography in the stored proc SqlCommand command = new SqlCommand(); command.CommandText = "dbo.up_Foobar_Insert"...

call to stored procedure returns nothing

I am calling a stored procedure on sql server like this: SqlConnection conn = new SqlConnection(); SqlCommand cmd; XmlDocument xmlDocument; XmlReader xr; XmlNode node; SqlDataReader rdr = null; try { xmlDocument = new XmlDocument(); conn.ConnectionString = "Data Source=test;Initial Catalog=teste;Integrated Security=SSPI;"; ...

Is there a general component/form for connecting to a database?

I need a form where I could easly select a database source (from file or network) using ODBC or any other data provider, but I don't want to code it myself. Are there any component or open source code that could save me the trouble? Thanks in advance. PS.: to be used with ADO.NET ...

Connection string cannot be created

I'm developing a website in that, i couldn't create connection string ,i have included all the required namespaces but when i create a string variable to store the connection it wont come in declaring SqlConnection object, but i can able to create connection string in constructor class,why i can't able to create connection outside const...

ADO.NET EF Composite primary key - can not update foreign key

I have following entities: In my code i need to update the FKCategoryID in entity BudgetPost but im getting error: FKCategoryID is part of the object's key information Is it any way to update the key in this case or it's not possible? Thanks in advance ...

How do I extract "eTag" or "x-ms-request-id" from my Azure Storage response?

The Azure table whitepaper mentions that the x-ms-request-id is useful to send to Microsoft in the event there is an error working with the data. If I do have such an error, I'd like my try...catch block to take this and save it somewhere for future analysis. How do I extract this information and have it available when the Exception co...

How can I tell if a given object has been saved using ADO.NET?

If I have a new object, that is not context.Saved() in ADO.NET, how can I tell that apart from another object that hasn't been saved? I'm going to use this information to determine how to handle my custom autoincrement feature. If the object has been saved to the database, I'll make a roundtrip to the database server. If the object ha...

How to get SQL Server CE TableAdapter to commit to database?

VS2008 project. Created local database (SSCE). Created dataset with tableadapter. Dragged dataset and tableadapter to the form so I can reference it in code. New records successfully add to the dataset but will not commit back to the database. Gives no error or clue why it won't work. TableAdapter insert statement was created autom...

How do I select 50 to 100 rows from Azure Table using the StorageClient?

I need to select several rows within a single partition of Azure Tables for later update. Since they all have the same PartitionKey, how do I structure my query to select multiple RowKeys? I'm interested in what the raw (on the wire) query should look like, and if possible the Linq query as well. I attempted this on my own and started...

Filtering SqlServer Command Timeout Exception for ExecReader

Hi, How do get the specific exception that has caused a sql server command to happen using the SqlException object that I have caught. I want to know when a Command timeout has occured, i.e. try { // database ExecReader call } catch (SqlException sqlEx) { // what can I test here to find if this is a command timeout exception } ...

Entity Framework Foreign Key Mapped to Same Table

This is not a duplicate of this post although the title is very similar. I am using EF4 with MSSQL Express 2008 R2 on VS2010. A simplified version of my schema is as follows: Table [Team]: Id (PK) Member1 Member2 Table [Person]: Id (PK) FirstName [Team].Member1 and [Team].Member2 are foreign keys pointing to [Person].Id. When ...