Category Archives: ADO.NET

Reset an Access autonumber field in C#

The post Get an autonumber value that was just inserted in C# explains how to use autonumbered fields. This post explains how you can reset the value used by an autonumber field. To reset an autonumber field in an Access … Continue reading

Posted in ADO.NET, database | Tagged , , , , , , , , , , , , | Leave a comment

Get an autonumber value that was just inserted in C#

If a database field is an autonumber field, then the database automatically generates values for it. For example, suppose a Students tables has typical fields such as FirstName, LastName, EnrollmentYear, and so forth. You could make the StudentId field be … Continue reading

Posted in ADO.NET, database | Tagged , , , , , , , , , , , | 1 Comment

Use SQL queries to display master-detail data in C#

This example uses SQL queries to load master-detail data only when it is needed. For quite a while now, the .NET-ish way to manipulate data from a database has been to load it into a DataSet stored in memory and … Continue reading

Posted in ADO.NET, controls, database | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , | 4 Comments

Generate random data in an Access database in C#

This example shows how you can generate random data for students and their test scores in an Access database. I often build examples that manipulate databases. Those examples are more interesting if the database holds lots of data, but it’s … Continue reading

Posted in ADO.NET, algorithms, database | Tagged , , , , , , , , , , , , , , | Leave a comment

Display master-detail data in a DataGrid in C#

At design time, I added the example’s Contacts.mdb database to the project, set its “Build Action” property to Content, and set its “Copy to Output Directory” property to “Copy if newer.” That way the database is copied into the executable … Continue reading

Posted in ADO.NET, controls, database | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Execute ad hoc SQL commands in C#

This example shows how you can execute ad hoc SQL commands such as CREATE TABLE and INSERT INTO in an Access 2007 database. ADO.NET itself doesn’t provide much in the way of objects to manipulate a database’s structure. Fortunately you … Continue reading

Posted in ADO.NET, database, SQL | Tagged , , , , , , , , , , , , , , | 2 Comments

Execute ad hoc SQL queries in C#

This example shows how you can execute an ad hoc SQL query at run time. Normally a program uses Recordsets, DataGrids, LINQ to SQL objects, and other database objects and controls to display and manipulate database records. Those techniques tend … Continue reading

Posted in ADO.NET, database, SQL | Tagged , , , , , , , , , , , , , | 3 Comments

Execute ad hoc database commands such as CREATE TABLE, INSERT INTO, DROP TABLE, and so forth in C#

Visual Studio provides lots of data-aware controls that can help you display and edit data, but it doesn’t include much in the way of objects to manipulate a database’s structure. It doesn’t include objects or methods that let you easily … Continue reading

Posted in ADO.NET, database | Tagged , , , , , , , , , | Leave a comment

A plea for help: Tell me what you want to see in my blog!

I get remarkably little feedback from my blog. I track post views and know that I have 857 Twitter followers, but people rarely let me know if they particularly like or dislike a post. That makes it hard for me … Continue reading

Posted in ADO.NET, algorithms, animation, API, challenges, combinatorics, controls, cryptography, curve fitting, database, extension methods, files, fonts, fractals, games, geometry, globalization, graphics, internationalization, LINQ, localization, mathematics, Office, phone, printing, reflection, registry, serialization, threading, transformations, user interface, Word, wpf, XAML, XML | 11 Comments