Tag: .net

Microsoft/SSRS report textbox returns #error when string value that is decimal is converted to decimal and empty string is just printed

I have a value that is coming back from a database as string, but it could be a decimal and when it is a decimal I want to display it as a decimal and format it a certain way, if it isn’t a decimal then I just display whatever value comes back. Here’s my code: […]

Move all database tables under another database with new Schema?

So I’ve been tasked with researching something I’ve never done before. 3 Application modules built using C# in VS2010 are using 1 database (Database1) with the tables such as dbo.Samples, which all have the schema “dbo.Table“. For some higher-up unknown reason, it has been requested that all these tables under Database1 be moved into Database2 […]

1 of x updates failed vs row not found or changed

I’m getting an inconsistent error in a program using linq on submitchanges that says “1 of x updates failed”. I’ve done some research on this and most of what I’ve found suggests that this is caused by data being used by the open data context being changed from elsewhere while the data is in memory. […]

Constraint with Sql statement

I have 2 tables 1.Sales_Items 2.Stock_Items I want to make sure that when any item is inserted in sale_items table then it’s qty must be less than (Stock_Items.qty-Sales_Items.Qty),if this condition is not true then insertion should fail and throw an exception. How should i do this?Do I need to use sql constraint with expression or […]

Does using C# CLR have any advantages over C# application?

I do some utility works to update databases which are simply gathering data from some websites and web services, and update related rows of database continously. I wrote an application on C# to do this. It is my bad, but I heard about using CLR for the first time today and googled it to make […]

TransactionScope Timeout overriden

I’ve dug around all over for this I can’t quite understand what I am seeing. This is not code that I wrote, so I am trying to understand what is going on. The bare bones are here : (action() is an Action object passed in. Basically something like this () => sp.BalanceAccounts(dto) try { TransactionOptions […]

Sql Parameter.Size and Output param

Untill now I have never specified the parameters size when calling a procedure with parameters. But suddenly one day i got an error: String[2]: the Size property has an invalid size of 0. I have never seen that before, and it only accured in an output param. So my question is when do I need […]

Batch process to delete rows from a SQL Server table

I’m developing a WCF RESTful service with C#, .NET Framework 4.0 and SQL Server. I have to do some maintenance every hour on database. I have to delete some rows from a table and update another one: A user can post three quotes of the day each 24 hours. I have to delete each quote […]

Copy part of a tables content and all records of other talbes referencing the copied records

I want to create a procedure (or .Net code) that can easily copy several records of a table. Every table uses a surrogate key as primary key. Therefore I might not be able to simply copy the desired records using something like “INSERT INTO SELECT” because they might reference a wrong record Table 1 Customer: […]

SQL query acessing multiple tables

It is working fine if just display the results from a single table. SqlCeCommand command = new SqlCeCommand(“SELECT Student.EnrolNo,Student.St_Name FROM Student”, ceConnection); SqlCeDataAdapter adapter = new SqlCeDataAdapter(command); DataSet set = new DataSet(); adapter.Fill(set, “Student”); ReportDocument document = new ReportDocument(); document.Load(@”C:\Users\user\documents\visual studio 2012\Projects\Student_Scholarship_management2\Student_Scholarship_management2\MainReport.rpt”); document.SetDataSource(set.Tables[0]); crystalReportViewer1.ReportSource = document; Now the above code is working fine as it […]

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