https://paste.ubuntu.com/24515932/
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
namespace Argede_WebService.Sql_Prosodur_Otomatik
{
public class Sql_Prosodur_DirektBaglanti
{
private List<Model> arrayliststatic = new List<Model>();
public class Model
{
public string Prosedur_Adi { get; set; }
public SqlDbType Prosedur_Tipi { get; set; }
public string Prosedur_YuklencekVeri { get; set; }
public string Prosedur_Nvarcharsa_Uzunluk { get; set; }
}
public bool Pro_Calistir(string prosedur_Adi)
{
SqlConnection myConnection = new SqlConnection("Data Source=" + staticdegerler.DataSource + ";Initial Catalog=" + staticdegerler.Catalog + ";Integrated Security=True");
bool response = true;
try
{
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = myConnection;
myConnection.Open();
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
sqlCmd.CommandText = prosedur_Adi;
foreach (Model eleman in arrayliststatic)
{
if (eleman.Prosedur_Tipi.Equals(SqlDbType.NVarChar))
{
sqlCmd.Parameters.Add(eleman.Prosedur_Adi, eleman.Prosedur_Tipi,Convert.ToInt32(eleman.Prosedur_Nvarcharsa_Uzunluk));
}
else
{
sqlCmd.Parameters.Add(eleman.Prosedur_Adi, eleman.Prosedur_Tipi);
}
sqlCmd.Parameters[eleman.Prosedur_Adi].Value = eleman.Prosedur_YuklencekVeri;
}
sqlCmd.ExecuteNonQuery();
myConnection.Close();
}
catch (Exception ex)
{
response = false;
}
return response;
}
public void ProsedurEkle(string Prosedur_Adi, SqlDbType tip, string veri, string charuzuluk)
{ // sqldatatype ayrı al
Model model = new Model();
model.Prosedur_Adi = Prosedur_Adi;
model.Prosedur_Tipi = tip;
model.Prosedur_YuklencekVeri = veri;
model.Prosedur_Nvarcharsa_Uzunluk = charuzuluk;
arrayliststatic.Add(model);
}
}
}
--------------------------
namespace Argede_WebService.Sql_Prosodur_Otomatik
{
public class staticdegerler
{
public static string DataSource = "AHMET";
public static string Catalog = "Argede_Next_Database";
}
}
Hiç yorum yok:
Yorum Gönder