oledb

In ADO.NET, are there restrictions where SQL parameters can be used in the SQL query?

笑着哭i 提交于 2019-12-02 06:02:33
问题 This question is merely for educational purposes, as I'm not currently building any application that builds SQL queries with user input. That said, I know that in ADO.NET you can prevent SQL Injection by doing something like this: OleDbCommand command = new OleDbCommand("SELECT * FROM Table WHERE Account = @2", connection); command.Parameters.AddWithValue("@2", "ABC"); But assuming that your application is designed in such a way that the user can actually enter the name of the table, can you

C# extract formatted text from Excel through OLEDB

若如初见. 提交于 2019-12-02 05:10:16
I am reading data from a large excel file which has got formatted texts. I extract the data to DataTable object through oleDBConnection & GetOleDbSchemaTable . But the extracted data doesn't include any formatted information. My requirement is, I need to extract only non-Strikethrough texts. I don't have any issues while reading and everything is perfectly fine. But my extraction should be based on text format in excel which I am unable to find the solution. Anything to be added in the connectionString which is as follows: connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +

SELECT @@IDENTITY in Access always returning 0

江枫思渺然 提交于 2019-12-02 05:06:58
I have been trying to find a solution to this problem but so far nothing worked. private void Insert() { string ConnectionStringAccess = Provider=Microsoft.ACE.OLEDB.12.0;Data Source=###Jet OLEDB:Database Password=###; string query2 = "Select @@Identity"; int id = -1; string Query = "INSERT INTO tblTable (EmpNo, Name) VALUES (132, 'TestName');"; OleDbConnection con = new OleDbConnection(ConnectionStringAccess); OleDbCommand cmd = new OleDbCommand(Query, con); try { con.Open(); if (cmd.ExecuteNonQuery() == 1)//the insert succeded { cmd.CommandText = query2; id = Convert.ToInt32(cmd

OleDB update command not changing data

亡梦爱人 提交于 2019-12-02 04:58:34
I'm using Microsoft Access file as database. I have no problem with SELECT and INSERT queries but when I try to UPDATE , record in database does not change. Below is the code I use to run update. There are no exceptions or errors in debug log. cnn = new OleDbConnection(connetionString); OleDbCommand command = new OleDbCommand("UPDATE [Wpisy] SET [wpis]=@wpis, [id_kat]=@id_kat, [tytul]=@tytul WHERE [ID]=@id_wpis" , cnn); command.Parameters.Add(new OleDbParameter("@wpis", tresc_wpisu.Text)); command.Parameters.Add(new OleDbParameter("@id_kat", lista_kategorii.SelectedValue)); command.Parameters

get column names Jet OLE DB in vb.net

拜拜、爱过 提交于 2019-12-02 04:54:11
问题 I've written a function which reads csv files and parametrizes them accordingly, therefore i have a function gettypessql which queries sql table at first to get data types and therefore to adjust the columns which are later inserted in sql. So my problem is when I set HDR=Yes in Jet OLE DB I get only column names like F1, F2, F3. To circumvent this issue I've set HDR=No and written some for loops but now I get only empty strings, what is actually the problem? here is my code: Private Function

ODBC or OleDB database drivers under Azure App Service

自古美人都是妖i 提交于 2019-12-02 04:54:02
问题 I'm investigating what's involved in deploying an ASP.NET MVC web application to Azure as an App Service, using Web Deploy from Visual Studio 2015. The MVC web application uses SQL Server for the identity database in the standard fashion, so I can see how to point that at an Azure-hosted database server. In addition, it has some 'legacy' data in DBF files in the App_Data folder, accessed on my development PC via OLEDB. This scenario is obviously going to fail on deployment because whatever

Syntax error in INSERT statement into MS Access

烈酒焚心 提交于 2019-12-02 04:26:37
问题 I couldn't find the syntax error in the following INSERT statement. public partial class doRegister : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\database"; using (OleDbConnection con = new OleDbConnection(str)) using (OleDbCommand cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO users (staffID,accessLevelIdD,username,password,email) VALUES (@staffID, '2', @username,@password,@email)";

How do I list all the queries in a MS Access file using OleDB in C#?

狂风中的少年 提交于 2019-12-02 03:56:24
问题 I have an Access 2003 file that contains 200 queries, and I want to print out their representation in SQL. I can use Design View to look at each query and cut and paste it to a file, but that's tedious. Also, I may have to do this again on other Access files, so I definitely want to write a program to do it. Where are queries stored an Access db? I can't find anything saying how to get at them. I'm unfamiliar with Access, so I'd appreciate any pointers. Thanks! 回答1: Procedures are what you're

system.data.oledb.oledbexception (0x80004005): could not find file

元气小坏坏 提交于 2019-12-02 03:32:05
Can someone help me with this error please? I can't figure it out. I have this error on Windows XP but not on Windows 7. What I did is i attached a photo and save it to the database (MS Access as my database). The photo appears on the picture box but then after that all is a mess. Im using C#. Do check that the path point to a mdb in the App_Data folder Not very sure but if the database is inside the App_Data folder, simply use: "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|StaffingSystem_DB.mdb" Your data file is an accdb file, thus requiring the ACE provider instead of the JET

Error External table is not in the expected format

佐手、 提交于 2019-12-02 03:27:26
问题 I am trying to get data to sqlserver2005 on my C# windows application, from sheet1.xls file through oledb connection in visual studio-2008 and I am using windows7 os and I didn't installed excel on my system. This is my connection string: string excelconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +excelfilepath + ";"+"Extended Properties='Excel 8.0;HDR=Yes;'"; I tried many ways but still i am getting this error : "External table is not in the expected format. " Please help