Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

C# GetData DataSet Function

Posted on May 21, 2015October 26, 2015 By David Kittell

Great for populating just about anything you can databind.

using System.Configuration;
using System.Data.SqlClient;
using System.Data;

private DataSet GetData(string query)
	{
		SqlCommand cmd = new SqlCommand(query);
		using (SqlConnection con = new SqlConnection(connString))
		{
			using (SqlDataAdapter sda = new SqlDataAdapter())
			{
				cmd.Connection = con;
				sda.SelectCommand = cmd;
				using (DataSet ds = new DataSet())
				{
					sda.Fill(ds);
					return ds;
				}
			}
		}
	}
Originally Posted on May 21, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp

Post navigation

Previous post
Next post

Related Posts

Update Ektron License

Posted on July 19, 2013October 26, 2015

After applying this update you will need to restart the services and in some case restart the server completely. SELECT lic_key FROM Settings SELECT module_license FROM module_licenses UPDATE Settings SET lic_key = ‘<License>’ UPDATE module_licenses SET module_license = ‘<License>’ Originally Posted on July 19, 2013Last Updated on October 26, 2015…

Read More

Android Contacts – Update Company Name

Posted on February 21, 2014October 26, 2015

UPDATE data SET data1 = "<Company Name>" WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%organization%" ) AND data1 LIKE "%<Company Name>%"; UPDATE data SET data1 = "<Company Name>" WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%organization%" ) AND raw_contact_id IN ( SELECT…

Read More

Create SQLite Database With Auto Increment

Posted on September 27, 2013December 30, 2015

Sub CreateTable(SQL As SQL, TableName As String, FieldsAndTypes As Map, PrimaryKey As String, Auto As Boolean) Dim sb As StringBuilder sb.Initialize sb.Append("(") For i = 0 To FieldsAndTypes.Size – 1 Dim field, ftype As String field = FieldsAndTypes.GetKeyAt(i) ftype = FieldsAndTypes.GetValueAt(i) If i > 0 Then sb.Append(", ") sb.Append("[").Append(field).Append("] ").Append(ftype)…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes