Skip to content
Advertisement

Tag: c#

EF6 Stored Procedure does not accept parameters

I am using EF6 and I need to execute stored procedure. It takes two parameters: mIIN varchar(12), which is input string mXMLOutput varchar(max), which is the result of execution It works fine when I call it from Management Studio. However, when I use the following code: which results in the error Procedure or function ‘GetInfo’ expects parameter ‘@mIIN’, which was

C# sql create one connection and open and close for each query

I recently inherited a C# Web app that creates a new connection for every query like so: I understand that this is typically the best way to do it, but is it acceptable or “best practice” to have the constructor create the connection object, and then have each method/Query open and then close that connection like so: I prefer the

Can’t retrieve data from SqlDataReader in C#

I need to insert values into several tables first I have to retrieve university id from table college and then insert faculty name into table faculty and get generated by SQL Server ID. After all of this I have to insert both ids into an other table. Problem is that I have to close readers and after I do it

Replace [ ] bracket in a string

I have a string that includes brackets, [], around a number. Since this string represents my column names for a SQL database I need to remove/replace them. So far I do it in the following way: It works fine, but it looks ugly for me since I have to do that for [1] to [20]. Is there a way to

Is there any function in C# like isnull in SQL?

In SQL server we can use “isnull” function for example if Table1 Contains Field1 and only one record which Field1 is null we can write this Query: which returns “0”. can we use any function like this in C#? for Example Consider textBox1 is Empty. and I want to Show “0”. Answer You can create an extension method: Sample Use:

Advertisement