ado.net

how to get column from Excel Sheet,if Excel sheet name contain space character i.e.“Person Details”

我的梦境 提交于 2020-01-05 04:23:05
问题 here i m using ADO.Net for connect to Excel file using specified connectionString that work fine, my only concern is if sheet name has space character than its not return column names form corresponding sheet. my code : if (extension == ".xls") { connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("~\\ExcelUpload\\Excelsheets\\temp.xls") + ";" + @"Extended Properties=" + "\"Excel 8.0;HDR=YES;\""; } else if (extension == ".xlsx") { connectionString = @

User-friendly error messages when removing row with Foreign Key REFERENCE constraint

眉间皱痕 提交于 2020-01-05 03:35:30
问题 What would be best practice to handle removal of db row that has FK REFERENCE constraint? My goal was to present more user-friendly error messages to the end-user. Note that I don t want to delete department with employees and that I don t want to have cascade delete on tables. For example if we have two tables: -- Department table CREATE TABLE [dbo].[Department]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, CONSTRAINT [PK_Department]

How to select the data by unicode where condition?

大兔子大兔子 提交于 2020-01-04 13:05:54
问题 I would like to get the data base on following SQL Statement and that was located in TableAdapter. SELECT * FROM Student WHERE Chinese_Name = @Param Example code call from C# is like this. GetDataByChinese_Name('你好'); But I have no idea where should I put the N prefix in that syntax. Usually, we can get SELECT * FROM Student WHERE Chinese_Name = N'你好' this way. 回答1: Your c# code should be slightly different. Use verbatim string literal.(msdn) GetDataByChinese_Name(@"你好"); 来源: https:/

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

岁酱吖の 提交于 2020-01-04 10:16:36
问题 Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds . I have one Stored Procedure Delete_OrdersByCustomerIds , which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string through to my stored procedure and use the following function to create a Table of Int's that I can join on: CREATE FUNCTION [dbo].[iter$simple_intlist_to_tbl

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

左心房为你撑大大i 提交于 2020-01-04 10:12:18
问题 Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds . I have one Stored Procedure Delete_OrdersByCustomerIds , which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string through to my stored procedure and use the following function to create a Table of Int's that I can join on: CREATE FUNCTION [dbo].[iter$simple_intlist_to_tbl

SQL - Is there a better way of passing a list of keys, for use in a where clause, into a Stored Procedure?

两盒软妹~` 提交于 2020-01-04 10:12:12
问题 Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have relating OrderIds . I have one Stored Procedure Delete_OrdersByCustomerIds , which deletes all the orders that are related to the CustomerIds specified. Currently, the way I do this is to concatenate the CustomerIds into a string, i.e. "1,2,3". I then pass this string through to my stored procedure and use the following function to create a Table of Int's that I can join on: CREATE FUNCTION [dbo].[iter$simple_intlist_to_tbl

Overriding rows affected in SQL Server using ExecuteNonQuery?

半城伤御伤魂 提交于 2020-01-04 09:28:41
问题 I have an insert statement that pulls some data into a few table variables and then based on that data does a few inserts into several tables. I only care about the rows that are inserted into the real tables and not the table variables, but ExecuteNonQuery will return the sum of all @@ROWCOUNT's. What I would like to know is there a way to override the rowcount that is returned using ExecuteNonQuery? I am aware that I can use ExecuteScalar or output variables as an alternative. Here is an

PL/SQL Procedure: How return a select statement?

≯℡__Kan透↙ 提交于 2020-01-04 08:19:23
问题 I want to create a stored procedure on ORACLE database server and my problem is that, I don't know how can I return a select statement . Here is the logic, which should within the procedure: Input paramters: filter1 (int), filter2 (string) with cte as ( select val1, val2, stddev(val3) from tab1 where parameter1 = filter1 and paramter = filter1 group by val 1, val2 ) SELECT cte.*, round(some calculation) as final_results FROM cte Afterwards I want to use this procedure in a MS asp.net

PL/SQL Procedure: How return a select statement?

落花浮王杯 提交于 2020-01-04 08:18:01
问题 I want to create a stored procedure on ORACLE database server and my problem is that, I don't know how can I return a select statement . Here is the logic, which should within the procedure: Input paramters: filter1 (int), filter2 (string) with cte as ( select val1, val2, stddev(val3) from tab1 where parameter1 = filter1 and paramter = filter1 group by val 1, val2 ) SELECT cte.*, round(some calculation) as final_results FROM cte Afterwards I want to use this procedure in a MS asp.net

ADO.Net or Entity Framework in Visual Studio 2008

丶灬走出姿态 提交于 2020-01-04 07:51:48
问题 If you were programming a small database application in .NET 2008 right now would use plain ADO.Net or ADO.Net Entity Framework or some of both both? I'm using Visual Studio 2008 to learn .Net. I already do quite a bit of programming in MS Access VBA but I've decided it's time to move past the desktop and past the 90's. My question is partially about what I should learn but also very much about what I should actually use in the real world. 回答1: Technically Entity Framework is the evolution of