ado.net

ASP how to make a login with password?

There's a table "Login" having values of "username" and 'password" coloumn's value in it. A login form in ADO.Net as frontend, and want to check if the value of "username and password" of form matches then the next form should be displayed. how should i do it with minimum lines of code. ...

Importance of closing SQLConnection objects when using the SQLDataReader object.

My present contract engagement is at a large E-Commerce company. Their code base which has origins going back to .Net 1.0 has caught me by surprise to contain many issues that raise the level of smell beyond the last crap I took. That notwithstanding and trying to diffuse my level of distraction from it, I go along merrily trying to ad...

ADO.NET: Adding DataRelation to a DataSet; which is parent and which is child?

Consider an SQL Server table containing: ID ParentID Text === ========= ============= 1 (null) Product 2 (null) Applications 3 1 Background 4 1 Details 5 2 Mobile i fill a SqlDataSet with the table, and now i want to add the Parent-Child relation to the DataSet: public DataRela...

Oracle Rollback Segments and ADO.NET

I am using an ancient version of Oracle (8.something) and my ADO.NET application needs to do some fairly large transactions. Large enough to not fin in our small rollback segments. Now we have a large rollback segment as well but it is not used by default. Oracle has a command to select the rollback segment to be used (SET TRANSACTION U...

Entity framework: One big model or a set of smaller models?

We been having some discussions on approaches to using the entity framework at work recently. We have a fairly large and complex n-tier web based application, which is due for a major overhaul. The question is: If we where to starting using the entity framework, would it be better to create one big model, or a set of smaller functional/...

Get output parameter value in ADO.NET

Hi, My stored procedure has an output paramter: @ID INT OUT How can I retrieve this using ado.net? public bool Blah() { using (SqlConnection conn = new SqlConnection(...)) { SqlCommand cmd = new SqlCommand("sproc", conn); cmd.CommandType = CommandType.StoredProcedure; // add parameters conn.Op...

Sproc Parameter Returning First Character Only

I've got a sproc and some C# calling it. My problem is that both the (N)VARCHAR values only have the first character returned. Everything else is fine. Why would only the 1st character be returned? So Content = (string)cmd.Parameters["@SmsContent"].Value, ToNumber = (string) cmd.Parameters["@ToNumber"].Value, both only get the 1st ch...

Tips for using Visual Studio Typed DataSets?

When using strongly typed dataSets in Visual Studio 2005/2008, if the underlying database schema changes, the only practical way to refresh is to delete the dataset and recreate it from scratch. This is OK unless I need to customize the dataset. Customizing by extending the partial dataset class allows customizations to be retained, b...

What's the best method to pass parameters to SQLCommand?

What's the best method to pass parameters to SQLCommand? You can do: cmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = "Bob"; or cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = "Bob"; or cmd.Parameters.Add("@Name").Value = "Bob"; It seems like the first one might be somehow "better" either performance-wise or err...

Building DB schema from Entity Framework Model

I see that EF can update a model based on an existing database schema. However, I'm starting totally from scratch; I don't want to build tables, then rebuild them in the EF model file. Is there a way that I can draw out a model file, and have the SQL tables automatically be created for me? ...

Retrieving "output messages" from batch SQL command (SQL Server)

I'm executing several discrete queries in a single batch against SQL Server. For example: update tableX set colA = 'freedom'; select lastName from customers; insert into tableY (a,b,c) values (x,y,z); Now, I want to capture the result in a DataSet (from select statement) which is easy enough to do...but how do I also capture the "m...

Handling updates to a Cached DataTable when the users session holds DataViews based on that DataTable

My website runs on a single server. I am caching a DataTable. Each session has a refernce to it's own DataView referring to that DataTable. What I am worried about is when I need to make changes to the underlying datatable will they propagate to each of the sessions references to it. Or is there a better way to handle this situation. ...

How do I get LongVarchar out param from SPROC in ADO.NET 2.0 with SQLAnywhere 10?

Hi All, I have sproc 'up_selfassessform_view' which has the following parameters: in ai_eqidentkey SYSKEY in ai_acidentkey SYSKEY out as_eqcomments TEXT_STRING out as_acexplanation TEXT_STRING  -  which are domain objects - SYSKEY is 'integer' and TEXT_STRING is 'long varchar'. I can call the sproc fine from iSQL using the following...

"Keyword not supported: " error in ASP .NET

i get a Keyword not supported: '192.168.1.1;initial catalog'. error when trying to do this Dim cn As New SqlConnection(str) where str is the connection string starts with '192.168.1.1;initial catalog' ... I have not specified the provider in the connection string ...

How do I improve performance of DataSet.ReadXml if I'm using a schema?

I'm have a ADO DataSet that I'm loading from its XML file via ReadXml. The data and the schema are in separate files. Right now, it takes close to 13 seconds to load this DataSet. I can cut this to 700 milliseconds if I don't read the DataSet's schema and just let ReadXml infer the schema, but then the resulting DataSet doesn't contai...

How to split Oracle sql statements for ADO.NET

What is the proper way to split up SQL statements to send to an Oracle ADO.NET client? For instance, lets say you have the following code in a text file and want to execute these statements: CREATE TABLE foo (bar VARCHAR2(100)); INSERT INTO foo (bar) VALUES('one'); INSERT INTO foo (bar) VALUES('two'); I believe trying to send all tho...

Should I commit or rollback a read transaction?

I have a read query that I execute within a transaction so that I can specify the isolation level. Once the query is complete, what should I do? Commit the transaction Rollback the transaction Do nothing (which will cause the transaction to be rolled back at the end of the using block) What are the implications of doing each? usin...

Batch Updates using DataAdapter

I have a situation where I have a bunch of SQL Update commands that all need to be executed. I know that DataSets can do batch updates, but the only way I've been able to accomplish it is to load the whole table into a dataset first. What if I want to only update a subset of the records in a table? ...

SqlCommandBuilder using table name instead of view

I am using a SqlCommandBuilder object to generate update statements from Select statements in a SqlDataAdapter. My problem is that in my Select statement I am selecting from a view called vwUsers. the SqlCommandBuilder object I used generated an update statement for the table Users not the view vwUsers. How can I override that behavior ...

TDD and ADO.NET Entity Framework

I've been playing with ADO.NET Entity Framework lately, and I find that it suits my needs for a project I'm developing. I also find cool its non-invasive nature. After generating a data model from an existing database you are faced with the task of integrating the generated model and your business logic. More specifically, I'm used to i...