ado.net

ADO.NET insert multiple values to SQL parameter

跟風遠走 提交于 2020-01-07 02:41:10
问题 I am receiving a Dictionary<string, string> and would like to forward its values to the DB inside SqlParameter . Is that even possible? This is the way I did it, and I am getting an error that column name doesn't match table definition. SqlParameter param = new SqlParameter(); param.ParameterName = "@Values"; var sb = new StringBuilder(); foreach (var item in data) { sb.Append("'" + item.Value + "', "); } param.Value = sb.ToString().TrimEnd(','); string insertString = $"insert into {tableName

ORA-00604 error while batch insertion inside TransactionScope

六月ゝ 毕业季﹏ 提交于 2020-01-06 20:08:42
问题 I am trying to batch insert 100k+ items to my Oracle db using ADO.NET inside a TransactionScope. Like this: using (TransactionScope transaction = new TransactionScope()) { while(/* Pagination logic - send insertion command on every 250 items */) { using (OracleCommand command = new OracleCommand(query, connection)) { command.ArrayBindCount = 250; //Add parameters command.Parameters.Add(":BLAH", OracleDbType.Long); command.Parameters[0].Value = LUC.ToArray(); command.ExecuteNonQuery(); //Error

How Do I insert Date and Time into SQL Server database in certain format? [duplicate]

陌路散爱 提交于 2020-01-06 18:07:37
问题 This question already has answers here : Insert into database date with another format (2 answers) Closed 4 years ago . I am using Windows forms in C#. I am trying to fill a table in a SQL Server database which contains DateTime column. Now when my PC's clock format is dd-MM-yyyy and when I try to insert the data with the following query, I get an error The conversion of a varchar data type to a datetime data type resulted in an out-of-range value Code: SqlConnection cn = new SqlConnection(

long varchar to string

微笑、不失礼 提交于 2020-01-06 15:02:45
问题 I am using a long varchar column to store log information. Now I want to retrieve it to a string, in C#, using a DataReader. However, there is an error: Request to retrieve BLOB column which had already been accessed. BLOB column may only be accessed once. 回答1: Maybe this url will help you: Retrieving ntext, text, or image Values Best regards 来源: https://stackoverflow.com/questions/18483262/long-varchar-to-string

Expected database model is inconsistent in real-time

こ雲淡風輕ζ 提交于 2020-01-06 14:20:42
问题 In this question, I was facing an issue where I was writing an update for a deployed application to bring the database up to date with the newer version we are deploying. Basic outline as follows: Began with currently deployed version of application Added new functionality that used existing database Added new database tables and relationships Added new functionality that depended on the new databse structure Testing complete, ready for deployment The issue here is that the currently deployed

Why am I getting an 'open data reader' exception with my SqlDependency subscription?

倾然丶 夕夏残阳落幕 提交于 2020-01-06 14:15:59
问题 I have finally, with an aggregate of an amazingly high numbers of dysfunctional examples, managed to receive change messages on a SqlDependency object. This knowledge may prepare you for the inelegance or plain incorrectness of my code. I have an ActiveList<T>: ObservableCollection<T> class that listens for changes to it's DB table data source and repopulates itself. I use the following code to create and initialize the list and the SqlDependency : Constructor: public ActiveList() {

Generate connection string dynamically in ASP.NET MVC

£可爱£侵袭症+ 提交于 2020-01-06 12:44:41
问题 Hi I am working on ASP.NET MVC project. Currently I am using Model first approach, where i used to add database manually by using ADO.NET model. Currently I have 4 database and I have 4 connection strings in web.config file. It was fine till now, since I was working on development environment. But now I need to move my code to live and problem is, in live we have like 40 to 50 databases. So what I should do is, generate connection string dynamically when user wants to connect to particular

How to insert/update rows from MySQL to SQL Server by using SSIS

那年仲夏 提交于 2020-01-06 08:27:12
问题 I'm looking for the best practice to insert or update rows from a MySQL connection to a SQL Server connection. First of all, I added a ADO.NET data source to grab MySQL content (a simple table Supplier with two fields id and name). Then, I added a Lookup transformation to split new rows / updated rows. It works well when I need to insert new rows. However, I would like to use a Command OLE DB to update existing rows but It doesn't work due to a incompatibility between my connection manager

Check for either ADO.NET / OLEDB Connection presence and then insert to DB

Deadly 提交于 2020-01-06 07:46:22
问题 I originally posted the question to check for presence of either ADO.NET/OLEDB connection types. That being resolved, I'd like to know, how to change the code when it comes to inserting to the DB. For example, when the connection type is ADO.NET we use the "Transaction" in the connection type. SqlConnection connection = (SqlConnection)connections[_connectionName].AcquireConnection(transaction); Now if I have the OLEDB connection (instead of ADO.NET), I'd like to handle that situation in this

Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt

依然范特西╮ 提交于 2020-01-06 07:23:12
问题 I have the following connection string using ado.net String ConectionString=@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Data.accdb; Jet OLEDB:Database Password=mypassword;" I faced the problem Microsoft.ACE.OLEDB.12.0 is not registered on local Machine I solved it By installing 64 version of the Microsoft Access Database Engine 2010. And edit Build Properties to x 86 But it never worked so I had to install 2007 Office System Driver :Data Connectivity components When I installed the