ado.net

How can I get Stored Procedure return value in C#?

谁都会走 提交于 2019-12-22 17:56:15
问题 I have a stored Procedure that do some operation and return 1 or 0 as below CREATE PROCEDURE dbo.UserCheckUsername11 ( @Username nvarchar(50) ) AS BEGIN SET NOCOUNT ON; IF Exists(SELECT UserID FROM User WHERE username =@Username) return 1 ELSE return 0 END and in C# i want to get this returned value i try ExcuteScalar but it didn't return any value ( i know if i replace return 0 with Select 0 ExcuteScalar will catach it .. but is it any way that allow me to get returned value with replace

Inserting all rows of a DataTable into a SQL Server table, including Id values

别说谁变了你拦得住时间么 提交于 2019-12-22 17:41:13
问题 I'm trying to insert the contents of a DataTable verbatim into a SQL Server database using ADO.NET. (Note: I'm using SQL Server CE at the moment, but I'd like a solution that works in either regular or CE.) Using the following code results in a command that does not include the Id column: var builder = new SqlCeCommandBuilder(); builder.DataAdapter = adapter; builder.SetAllValues = true; var command = builder.GetInsertCommand(true); This causes the Id to be auto-generated, which is not what I

Is anyone using System.Data.SQLite within SharpDevelop?

[亡魂溺海] 提交于 2019-12-22 16:43:40
问题 I was just wondering if perhaps any of you guys has been successful integrating SQLite into a SharpDevelop project? If that's the case it'd be really interesting if you wouldn't mind to go ahead and share the experience with the rest of us. I've tried the more sort of orthodox approach of using Visual Studio 2008 Express Editions and whatnot but, although it apparently plays well with Visual Web Developer , unfortunately the SQlite.NET package fails to work with Visual C# , so SharpDevelop is

Grabbing extended properties from SQL Server into DataTable

谁说胖子不能爱 提交于 2019-12-22 11:34:11
问题 I have a view called PersonOverview which has a bunch of columns; it's a totally normal view, nothing special about it. I added an extended property called FlexGridHide with a value of 1 to the DatenbereichCD column of that view using. EXEC sys.sp_addextendedproperty @name = N'FlexGridHide', @value = N'1', @level0type = N'SCHEMA', @level0name = dbo, @level1type = N'VIEW', @level1name = vPersonOverview, @level2type = N'COLUMN', @level2name = DatenbereichCD; I can find that extended property in

Invoking ADO.NET from MATLAB

元气小坏坏 提交于 2019-12-22 10:27:24
问题 It's possible to call .NET from MATLAB, so I thought I would try to use ADO.NET to connect to a database. I seem to have hit a blocking problem - anytime you try and create a Command object, it throws an error. You can try this yourself: >> NET.addAssembly('System.Data'); >> sqlconn = System.Data.SqlClient.SqlConnection(); >> sqlconn.State ans = Closed >> % So far, so good >> sqlcmd = System.Data.SqlClient.SqlCommand(); ??? Error using ==> System.Data.SqlClient.SqlCommand 'Connection' is

Entity Framework with SQLite exception: The underlying provider failed on Commit

大兔子大兔子 提交于 2019-12-22 10:17:38
问题 I'm using the Entity Framework (.NET 4.0) with SQLite as the underlying database and I get an exception when I try to commit some changes to the database: The underlying provider failed on Commit. The stack trace is: System.Data.EntityException: The underlying provider failed on Commit. ---> System.Data.SQLite.SQLiteException: The database file is locked database is locked at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt) at System.Data.SQLite.SQLiteDataReader.NextResult() at System

Passing a boolean type into a bit parameter type in C# and MS SQL Server

走远了吗. 提交于 2019-12-22 07:42:32
问题 I have a C# method that accepts a clientId (int) and hasPaid (boolean) that represents if the client has paid or not. The MS SQL Server stored procedure expects a BIT value (1 or 0) for the @HasPaid parameter yet the method expects a boolean type (true/false) for hasPaid. Will the ADO.NET code take care of converting the boolean to a bit type for SQL Server or do I need to convert the value of hasPaid into a 1 or 0 ? public void UpdateClient(int clientId, bool hasPaid) { using (SqlConnection

MySql Connector with EF 6

眉间皱痕 提交于 2019-12-22 07:06:30
问题 I am having a weird issue with MySql Connector(6.8.3) and EF6. I was working on a WebApi project where I use MySql and EF6 with Database first approach. Everything worked fine[even deployed on one of the test servers] until I changed the database from 'Test' database to 'Production' database [just the database name] in the connection string and updated the model[just to see nothing is broken!]. After that, it failed to connect to database. So, I changed the connection string back and rebuilt

Can you use DataTable.Contains(object key) if your datatable's primary key is two columns?

你。 提交于 2019-12-22 06:33:13
问题 if so how? 回答1: To select by a primary key you should use one of: DataTable.Rows.Find(Object) in case your PK is one column DataTable.Rows.Find(Object[]) in case you have more then 1 column as a primary key In case of a typed DataSet, the method MyDataTable.Rows.Find(...) will be generated for you with the proper signature. Basically it is a method on DataRowCollection class 回答2: 'Contains' does not seem to be a member of the DataRow class (maybe this is a typed data set?) In any case, you

What is the best way to load huge result set in memory?

对着背影说爱祢 提交于 2019-12-22 05:50:09
问题 I am trying to load 2 huge resultsets(source and target) coming from different RDBMS but the problem with which i am struggling is getting those 2 huge result set in memory. Considering below are the queries to pull data from source and target: Sql Server - select Id as LinkedColumn,CompareColumn from Source order by LinkedColumn Oracle - select Id as LinkedColumn,CompareColumn from Target order by LinkedColumn Records in Source : 12377200 Records in Target : 12266800 Following are the