Tag: .net

Is there an automated way to update an entity model with the Entity Framework?

It seems at this point all one can do is manually update it from within Visual Studio, recompile the assembly then deploy. Is that the only way? Or is there an easier, automated method of doing so?

Uploading a csv file to sql server – Identity problem

Given a column structure in a CSV file of: First_Name, Last_Name, Date_Of_Birth And a SQL Server table with a structure of ID(PK) | First_Name | Last_Name | Date_Of_Birth (Field ID is an Identity with an auto-increment of 1) How do i arrange it so that SQL Server does not attempt to insert the First_Name column […]

What happens if network is lost while rolling back transaction with TransactionScope in .Net

I have this following code:- using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required)) { bool IsCreated=false; context.CommandTimeout = 120; if(IsCreated) transactionScope.Complete(); } Now If transactionScope.Complete() is not called, Transaction is rolled back once scope of using is Complete. However IF before this there is a network outage, how will this transaction be rolled back. It is rolled […]

Is there any way to show records that are preventing a delete due to referencial integrity?

i have a generic problem all over my application and want to see if there is a common generic way of solving it. The main issue is how to let users know which records are linked when you try to delete a record from a joined table. for example, let’s say i have two database […]

Is there an overload to add sqlparameters with name, type, value

When adding parameters to a SQLCommand, is there an overload that includes ‘parameter name’, ‘type and ‘value’ otherwise i end up writing something like: using cmd as new SQLCommand(“SELECT x FROM y WHERE z = @z”, cn) Dim p0 as SQLParameter = cmd.Parameters.Add(“@z”, SQLDbType.Int) p0.Value = 1 end using I would like a one liner […]

Mapping duration with NHibernate

I have a database view (Sql Server 2005) that has a column Duration (EndDate – StartDate) and I want that to be mapped to a TimeSpan property in .NET. So far my best guess is to convert it in the view to an int, like this: DATEDIFF(ms, StartDate, EndDate) * 10000 AS Duration … but […]

Common Import Process

I am looking at creating a common import routine for various parts of my company’s main system to be used when implementing a new client. For example, we may get excel or csv files of inventory, customers, etc. that needs to be imported into a common model. I was wondering if anyone had some good […]

sql server creation of logins and users by another user

I am using SQL Server Express 2005. I have a single database myDB I have created a Login L-1 with user U-1 on databas myDB. To Connect to database myDB i found 3 ways: -1(a)-after creating L-1 Login with default database = myDB , i have to create a user U-1 , and when i […]

How can I display differently from the database a field from a record, after the execution of a SELECT statement?

I created a Crystal Reports report viewer in my WindowsForm application. When the form that contains the report viewer is loaded, the data is loaded into the report using the a fill method created from the TableAdapter Query Configuration Wizard. There is a column in my database which the type is a single bit. So […]

Serializing XML to objects

To map our relation data to objects, we return XML data and deserialize to objects. In order to use this approach, the objects being deserialized needed to have a public default constructor. What I used to do which was more work was return a dataset and write code to populate my objects manually through constructors. […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.