Copyriht © 2011 PcDr SysDba
  Class ( Dba Bağlantılı )
 

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.ComponentModel;
using FirebirdSql.Data.FirebirdClient;

namespace SQL_SORGU_ARŞİVİ
{
    public class CLS_SORGU
    {
        private static FbConnection con;
        private static FbDataAdapter adapter;
        //private static DataTable dt = null;
        static string FSelectQuery = "";


        public static void Baglan()
        {
            con = new FbConnection("data source=127.0.0.1;user id=SYSDBA;initial catalog=C:dataSQL.GDB;password=masterkey");
            con.Open();
            if  (adapter==null) adapter = new FbDataAdapter();
          
        }

        public static void BaglantiKes()
        {
            //dt.Dispose();
            adapter.Dispose();
            con.Close();
            con.Dispose();
        }

        public  static void cmdAyarla()
        {
            string aQry = "";
            aQry = "INSERT INTO SORGU VALUES (@SIRA_NO, @MODUL_KODU,@SORGU_ADI,@SORGU_ACK)";
            adapter.InsertCommand = new FbCommand(aQry, con);
            verParametre(adapter.InsertCommand);
            aQry = "UPDATE sorgu SET MODUL_KODU = @MODUL_KODU, SORGU_ADI = @SORGU_ADI,SORGU_ACK=@SORGU_ACK WHERE SIRA_NO = @SIRA_NO";
            adapter.UpdateCommand = new FbCommand(aQry, con);
            verParametre(adapter.UpdateCommand);
            aQry = "DELETE FROM SORGU WHERE SIRA_NO = @SIRA_NO";
            adapter.DeleteCommand = new FbCommand(aQry, con);
            verParametre(adapter.DeleteCommand);
        }

        private static void verParametre(FbCommand Acmd)
        {
            FbParameter param = null;
            if (Acmd == adapter.DeleteCommand)
            {
                param = adapter.DeleteCommand.Parameters.Add("@SIRA_NO", FbDbType.Integer);
                param.SourceColumn = "SIRA_NO";
                param.SourceVersion = DataRowVersion.Original;
            }
           else
            {
                param = Acmd.Parameters.Add("@SIRA_NO", FbDbType.Integer);
                param.SourceColumn = "SIRA_NO";
                param.SourceVersion = DataRowVersion.Original;
                param = Acmd.Parameters.Add("@MODUL_KODU", FbDbType.VarChar);
                param.SourceVersion = DataRowVersion.Current;
                param.SourceColumn = "MODUL_KODU";
                param = Acmd.Parameters.Add("@SORGU_ADI", FbDbType.VarChar);
                param.SourceVersion = DataRowVersion.Current;
                param.SourceColumn = "SORGU_ADI";
                param = Acmd.Parameters.Add("@SORGU_ACK", FbDbType.Text);
                param.SourceVersion = DataRowVersion.Current;
                param.SourceColumn = "SORGU_ACK";
            }
        }

        private static  DataTable alListeSORGU()
        {
            FSelectQuery = "SELECT * FROM SORGU";
            adapter.SelectCommand = new FbCommand(FSelectQuery, con);
            DataTable dt = new DataTable("SORGU");
            adapter.Fill(dt);
            return dt;
        }

        public static DataTable ListeSORGU
        {
            get
            {
                return alListeSORGU();
            }
        }

        public static FbDataAdapter AlDataAdapter()
        {
            return adapter;
        }

        public static void Kaydet(DataTable dt)
        {
            //try
            //{
                adapter.Update(dt);
            //}
            //catch (Exception ex)
           // {
           //     Console.Write(ex.ToString());
            //}
        }
    }
    }
 

 
 
  Bugün 10 ziyaretçi (11 klik) kişi burdaydı!  
 
Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol