6 Şubat 2018 Salı

Sql Server Connection String oluşturma

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace FirmaOtomasyonuDesktop
{
    public static class AppDb
    {
        private static SqlConnection Bağlantı = null;
       
        public static bool InitDb()
        {
            try
            {
                Bağlantı = new SqlConnection();
                Bağlantı.ConnectionString = "Data Source=127.0.0.1; Initial Catalog=HELLOSQL; User id=sa; Password=2002;";
                Bağlantı.Open();
                return true;
            }

            catch (Exception ex)
            {
                AppUtil.mesajHata("Veri tabanı baplantısı yapılırken beklenmedik bir hata oluştu program kapatılıyor...", ex);
                return false;
            }
        }
        public  static SqlDataReader GetReader(string prmSql)
        {
            using (SqlCommand Cmd = new SqlCommand(prmSql, Bağlantı))
            {
                return Cmd.ExecuteReader();
            }
        }
        public static bool ExecuteSql(string prmSql)
        {
            try
            {
                using (SqlCommand Cmd = new SqlCommand(prmSql, Bağlantı))
                {
                    Cmd.ExecuteNonQuery();
                }

                return true;
            }
            catch (Exception ex)
            {
                AppUtil.mesajHata("Sorgu Çalıştırıken beklenmedik bir hata oluştu", ex);
                return false;
            }
            }
        }

    }

Hiç yorum yok:

Yorum Gönder

Mac adres formatı excel

excel iki nokta mac addres formatı Mac adresi karakterlerini üst üste iki nokta : iki nokta üst üste olacak şekilde excel dosyasında ayırır....