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

Execute SQL

Posted on April 20, 2015October 26, 2015 By David Kittell
 protected void ExecuteNonQuery(string sql)
    {
        SqlConnection sqlConn = new SqlConnection();
        try
        {
            string connString = ConfigurationManager.ConnectionStrings["DbConnection"].ToString();
            sqlConn.ConnectionString = connString;
            sqlConn.Open();
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConn);
            sqlCommand.ExecuteNonQuery();
        }
        catch(Exception ex)
        {
            labelSuccess.Text = ex.Message;
        }
        finally
        {
            if(sqlConn.State == System.Data.ConnectionState.Open)
            {
                sqlConn.Close();
            }
        }

    }
Originally Posted on April 20, 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

C# ASPX Code CSharp MSSQL SQL

Post navigation

Previous post
Next post

Related Posts

Ektron Find Replace In Menu

Posted on October 23, 2013October 26, 2015

This script will rename menu link paths SET XACT_ABORT ON DECLARE @currval NVARCHAR(500) DECLARE @newval NVARCHAR(500) DECLARE @search NVARCHAR(500) DECLARE @replace VARCHAR(500) SET @search = ” –string to find SET @replace = ” –replacement string DECLARE @pos INT DECLARE @id BIGINT BEGIN TRAN DECLARE curs CURSOR LOCAL FAST_FORWARD FOR SELECT…

Read More

Draw an arrow within a box

Posted on December 20, 2013October 26, 2015

Imports System.Drawing Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint ‘ Create pen. Dim blackPen As New Pen(Color.Black, 3) ‘ Create triangle. Dim point1 As New Point(15,…

Read More

Android Contacts – Clear Name If It Matches Company Name

Posted on February 21, 2014October 26, 2015

UPDATE data SET data1 = NULL ,data2 = NULL ,data3 = NULL WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%name%" ) AND raw_contact_id IN ( SELECT raw_contact_id FROM data dt1 INNER JOIN mimetypes ON mimetype_id = mimetypes._id WHERE mimetype LIKE "%name%" AND length(data1) > 0 AND…

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