ado.net

Stored procedure or function expects parameter which was not supplied

对着背影说爱祢 提交于 2019-12-19 14:46:43
问题 I am trying to insert data into a SQL Server database by calling a stored procedure, but I am getting the error *Procedure or function 'Insertion' expects parameter '@Emp_no', which was not supplied* My stored procedure is called Insertion . I have checked it thoroughly and no parameters is missing also I have checked it by using a label. The label shows the value but I don't know why I am getting the error. My code is try { SqlCommand cmd = new SqlCommand(); cmd.Parameters.Clear(); cmd

How to insert value into primary key identity column in SQL through C#?

本小妞迷上赌 提交于 2019-12-19 12:30:07
问题 (My problem solved. As almost everyone said I had to remove @OB_ID and left it to SQL to assign value.) I want to insert a new record into a table in SQL database through C# code. The primary key is identity. How can I make Visual Studio understood that the column is identity so SQL Server must set the value. Here's the related code: SqlConnection sqlc = new SqlConnection(); sqlc.ConnectionString = "Data Source=. ; Database=LDatabase; Integrated Security=true;"; SqlCommand cmd2 = new

Databinding to a programmatically created DataTable

给你一囗甜甜゛ 提交于 2019-12-19 12:23:47
问题 Suppose I have a datatable like this: DataTable dt = new DataTable("Woot"); dt.Columns.AddRange(new DataColumn[]{ new DataColumn("ID",typeof(System.Guid)), new DataColumn("Name",typeof(String)) }); When I try to bind a control to it: this.txtName.DataBindings.Add("Text", _dtRow, "Name"); I get this exception: Cannot bind to the property or column Name on the DataSource. Parameter name: dataMember Any idea why this works on a datatable created by a dataAdapter, but not on a programmaticly

Do I Still Need To Install Oracle Client if Using Microsoft ODBC for Oracle to connect to an Oracle Database?

柔情痞子 提交于 2019-12-19 10:19:49
问题 Using ActiveX Data Objects 2.8 Library as a Reference from Excel VBA, and the connection string is: "Driver={Microsoft ODBC for Oracle}......." And I also have the "Microsoft ODBC for Oracle" (MSORCL32.dll) entry in the Drivers tab of Windows XP's ODBC Manager. Now, will I be able to connect to an oracle databse, without any oracle client/products installed on my machine? 回答1: I'm pretty sure you need to install Oracle client; what's more, I believe it has to be Oracle 8 Client (MS hasn't

Do I Still Need To Install Oracle Client if Using Microsoft ODBC for Oracle to connect to an Oracle Database?

蹲街弑〆低调 提交于 2019-12-19 10:19:19
问题 Using ActiveX Data Objects 2.8 Library as a Reference from Excel VBA, and the connection string is: "Driver={Microsoft ODBC for Oracle}......." And I also have the "Microsoft ODBC for Oracle" (MSORCL32.dll) entry in the Drivers tab of Windows XP's ODBC Manager. Now, will I be able to connect to an oracle databse, without any oracle client/products installed on my machine? 回答1: I'm pretty sure you need to install Oracle client; what's more, I believe it has to be Oracle 8 Client (MS hasn't

Entity Framework ObjectContext -> raw SQL calls to native DBMS

二次信任 提交于 2019-12-19 08:55:06
问题 I have an app using the ADO.NET entity framework (the VS2008 version, not the newer, cooler one) and I need to be able to make a call down to the underlying DBMS (it's postgres) in order to call some SQL that Entity Framework doesn't support. Is there a way to go from an Entity Framework ObjectContext to something that will let me execute raw SQL? (I need to run a TRUNCATE TABLE before inserting) I'm OK with a hacky solution (e.g. pull out the DBMS's connection string info from EF, and use

Getting table schema from a query

筅森魡賤 提交于 2019-12-19 06:31:01
问题 As per MSDN, SqlDataReader.GetSchemaTable returns column metadata for the query executed. I am wondering is there a similar method that will give table metadata for the given query? I mean what tables are involved and what aliases it has got. In my application, I get the query and I need to append the where clause programically. Using GetSchemaTable() , I can get the column metadata and the table it belongs to. But even though table has aliases, it still return the real table name. Is there a

Executing stored proc from DotNet takes very long but in SSMS it is immediate

给你一囗甜甜゛ 提交于 2019-12-19 06:26:10
问题 I have a stored proc on SQL Server 2000 that takes 3 parameters. When I call the stored proc from DotNet using SqlCommand.ExecuteReader () it takes about 28 seconds. When I run the same query inside SSMS directly it returns immediately. When I take the query out of the stored proc and run it directly using DotNet it also returns immediately. These are the results from a SQL Profiler session SP Inside Dot Net Duration: 28030 Reads: 2663365 Writes: 0 SP Inside SSMS Duration: 450 Reads: 23535

Get value of Oracle OUT parameter from a stored procedure call using Dapper.NET

折月煮酒 提交于 2019-12-19 05:51:17
问题 Edit: Using the Execute method instead of the Query / QueryMultiple methods, my OUT_SUCCESS parameter now has an AttachedParam with with an OracleParameter that has the returned value. So this would work if, for instance, I only needed to retrieve non-cursors parameters. Then I could use Execute for procedures with all non-cursor output parameters and Query / QueryMultiple for procedures with only cursor output parameters. But what if I need to call a stored procedure that has both cursor and

Get value of Oracle OUT parameter from a stored procedure call using Dapper.NET

大憨熊 提交于 2019-12-19 05:50:30
问题 Edit: Using the Execute method instead of the Query / QueryMultiple methods, my OUT_SUCCESS parameter now has an AttachedParam with with an OracleParameter that has the returned value. So this would work if, for instance, I only needed to retrieve non-cursors parameters. Then I could use Execute for procedures with all non-cursor output parameters and Query / QueryMultiple for procedures with only cursor output parameters. But what if I need to call a stored procedure that has both cursor and