ADO.NET

Implementing SQL Server Full-Text Search In An ASP.NET MVC Web Application With Entity Framework

calendar_today 13 May 2016 08:13

SQL ADO.NET ASP.NET MVC Entity Framework

The search facility on this site has been rudimentary at best. I have recently upgraded it to take advantage of the Full-Text Search feature in SQL Server. Although it is still a basic implementation, it is a vast improvement on the search system that existed before, which was based on Entity Framework dynamically generating SQL LIKE clauses. This article describes how I got SQL Server Full-Text Search up and running.

The Best Way To Import Data From Excel To SQL Server via ASP.NET

calendar_today 14 April 2016 13:42

ADO.NET ASP.NET MVC ASP.NET Web Forms ASP.NET Web Pages EPPlus

I've seen a lot of questions about the best way to import data from uploaded Excel files to a SQL Server database in an ASP.NET application. Most solutions involve the use of the JET or ACE OLEDB providers to read data from the saved Excel file, and some even show how to use Office Interop to obtain the data. However, all of these solutions rely on additional components being installed on the server, and they also require the uploaded file to be saved somewhere, even temporarily, which creates an additional maintenance task. The solution that follows makes use of a Nuget package that gets deployed with your application and can work with streams, so the uploaded file doesn't need to be saved. It is, in my submission, THE best way to import data from uploaded Excel files to SQL Server in an ASP.NET application.

Solved - The Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine

calendar_today 23 July 2015 20:05

MS Access ADO.NET EPPlus

There are a number of reasons why you might get "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" error when attempting to connect to either an accdb or an xlsx file, depending on what you are doing. This article discusses some of the causes and provides solutions first for uses involving ASP.NET, and then looking at other application uses.

ASP.NET MVC is not all about Linq to SQL

calendar_today 21 February 2010 08:21

ADO.NET ASP.NET MVC

Pretty much every sample application that illustrates ASP.NET MVC uses Linq To SQL or the Entity Framework as the data access method. I've seen a number of questions posted to the forums at www.asp.net asking if there are any alternatives, and indeed there are. This article will look at using plain ADO.NET within a data access layer to provide dynamic content to a typical small CRUD application.

Parameterized IN clauses with ADO.NET and LINQ

calendar_today 28 September 2009 21:53

C# ADO.NET LINQ ASP.NET 3.5

Since my article on using parameters for Preventing SQL Injection In ASP.NET, I have had a few emails asking how to do the same with an IN clause expression. In this entry, I explore a couple of ways to do this.

Preventing SQL Injection in ASP.NET

calendar_today 19 August 2009 07:28

SQL ADO.NET ASP.NET 3.5

I, and many other contributors to the forums at www.asp.net find examples of code posted on a daily basis that are vulnerable to SQL Injection attacks. We continue to exhort beginners (and some more experienced programmers) to code against them. This article examines just how serious a flaw vulnerable coding can be, and what you should do about it.

Import Data From Excel to Access with ASP.NET

calendar_today 09 July 2008 09:19

ASP.NET 2.0 MS Access ADO.NET ASP.NET Web Forms

Building on my previous article on importing text files of various formats to an Access database, here's how to do the same thing simply and efficiently with Excel files.

AccessDataSource, SqlDataSource and connecting to Access databases in ASP.NET

calendar_today 17 May 2008 09:48

ASP.NET 2.0 MS Access ADO.NET ASP.NET Web Forms

There are a variety of options for connecting to Access databases within ASP.NET pages. This article attempts to cover the choices and offer recommendations for getting the best out of Access.

80040E14 - MS Access Syntax Error messages

calendar_today 01 May 2008 11:06

ASP.NET 2.0 MS Access ADO.NET ASP.NET Web Forms

This short article deals with the following common MS Access-related error messages:

Simple Login and Redirect for ASP.NET and Access

calendar_today 01 May 2008 10:02

ASP.NET 2.0 MS Access ADO.NET ASP.NET Web Forms

Quite often, I see questions asked about creating a simple login page for use with Access from people who don't want to take advantage of the built-in Forms Authentication framework within ASP.NET. The following samples show how relatively easy this is to accomplish.

Solving the Operation Must Use An Updateable Query error

calendar_today 30 April 2008 22:48

ASP.NET 2.0 MS Access ADO.NET ASP.NET 3.5

The unbelievably cryptic Operation Must Use An Updateable Query error is the bane of developers who are just starting out with Access and ASP.NET. You've done your code, plopped your database file in the App_Data folder (or at least, you should have done), and try to run a page that INSERTs or UPDATEs records, and it all stops dead. This brief article explains the cause of the error, and the steps required to stop it recurring.

Sql JOINS and the Sql Server Management Studio Query Designer

calendar_today 28 November 2007 13:19

SQL SQL Server Express ADO.NET

There are a whole bunch of articles, blog entries and tutorials that seek to explain how SQL JOINS work. Some of them are excellent, and others are just confusing. The reason I am adding my go at trying to clarify JOINS to the mix is to highlight how proper use of the tools available to you can seriously reduce the chances of getting the JOIN syntax or type wrong. Since JOINS are all about how to relate data from one table to another, I thought it appropriate to illustrate the subject using Parents and Children (who may, or may not be related to eachother). So let's meet the families.

Migrating from Sql Server to Access in ASP.NET

calendar_today 16 November 2007 10:45

MS Access ADO.NET

Yes, you did read that correctly. Here's the situation: you know that Sql Server is by far the superior database system (if indeed MS Access can be called a database system). You also know that MS Access databases are not recommended as a data store for web applications. You are comfortable with Sql Server, and haven't really looked at Access for years - if at all. But now, your boss or your client wants you to use it in the next project.

An ASP.NET Search Engine with MS Access for optional search criteria

calendar_today 12 November 2007 15:15

ASP.NET 2.0 MS Access ADO.NET ASP.NET Web Forms

Creating a search interface for one user-supplied value is pretty straightforward: a TextBox for input, a Button and some SQL that searches one or more fields where the values are LIKE '%' + @searchterm + '%' is all that is needed. While it works, this approach is not very flexible. For example, what if you wanted to search for an Employee whose last name contains "a", and don't want those where the first name or city contains "a"? The traditional solution to this is to dynamically construct the SQL statement based on what values were passed by the user. However, building the SQL string can get repetitive, boring and messy. Here is a cleaner way to allow the user to narrow down searches across multiple criteria with the use of optional parameters, and just 3 lines of programming code.

Reading Text files into Access with ASP.NET

calendar_today 09 September 2007 21:20

MS Access ADO.NET

The Jet 4.0 OLEDB driver is a remarkable beast. Not only will it allow connections to MS Access .mdb files and MS Excel spreadhseets, but it will also allow you to connect to and query a variety of text file formats. Here are some examples that illustrate this capability when applied to importing text based data into Access.

Bind Data From a SqlDataSource to a Label

calendar_today 25 August 2007 10:32

ASP.NET 2.0 ADO.NET ASP.NET Web Forms

Label controls in ASP.NET don't have a smart tag that allows you to select a data source, so at first glance, it is not easy to see how to bind a value returned from a SqlDataSource or AccessDataSource control to the label. Here's how to programmatically access the data returned by such a DataSource and apply it to a non-databound control.

Exporting data to a CSV, tab delimited or other text format

calendar_today 02 August 2007 23:41

ASP.NET 2.0 ADO.NET

A question that often comes up in forums is how to export data to a CSV file, or other text format. Here's a method that takes data from a DataReader and writes it to a file.

Displaying One-To-Many Relationships with Nested Repeaters

calendar_today 27 July 2007 14:24

ASP.NET 2.0 ADO.NET ASP.NET Web Forms

This item could also have been entitled "Displaying Master-Detail Data" or "Displaying Categorised Data", but the principal is the same: you have what are essentially headings or categories, and a group of entries that belong to each heading that you want to display. Typical examples would include the Models of cars by Manufacturer, or Employees by Department. Here's how to do it quite simply using nested Repeaters.

Getting the identity of the most recently added record

calendar_today 05 June 2007 22:13

SQL SQL Server Express MS Access ADO.NET

The built-in functions @@Identity and Scope_Identity() are designed to retrieve the most recently added record's autoincrement identity value from Access and Sql Server respectively. Here are some usage examples.

Programmatically accessing data from DataSource controls

calendar_today 16 May 2007 10:06

C# ASP.NET 2.0 ADO.NET

For the main part, the DataSource controls are incredibly easy to work with. You just drag them onto your page in Design View, wire them up to a connection and provide some kind of command (ad hoc sql query or the name of a stored procedure - saved query in Access), then link them to a databound control on the page using its DataSource property. Then you run the page and all your data appears. But what if you want to get at one or more values from the returned data to do something else with it, like display it in a control that doesn't expose a DataSource property?

Binding data to a DropDownList with ADO.NET

calendar_today 11 May 2007 22:35

ASP.NET 2.0 MS Access ADO.NET

Using ADO.NET to pull data from the Northwind database (Access version), using the saved query Current Product List.

Parameter Queries in ASP.NET with MS Access

calendar_today 13 April 2007 22:17

ASP.NET 2.0 MS Access ADO.NET

A selection of code samples for executing queries against MS Access using parameters.

Iterating through CheckBoxList To Insert Records

calendar_today 03 April 2007 20:52

ASP.NET 2.0 ADO.NET

Having inserted a record, you want to retrieve the newly created record's ID number, then iterate over a collection of items, such as a CheckBoxList to insert additional information relating to the record.

Insert Single Value With Stored Procedure ASP.NET C#

calendar_today 03 April 2007 14:16

ASP.NET 2.0 SQL ADO.NET

Code for calling stored procedure in the Code-Behind to insert a single value from a text box.