clsDataBaseInfo clsMailDBService_EntsvcExecuteDataSet(string querystring) { try { SqlConnection conn = new SqlConnection(VMuktiInfo.MainConnectionString); SqlCommand cmd = new SqlCommand(querystring, conn); SqlDataAdapter sda = new SqlDataAdapter(cmd); clsDataBaseInfo dbContract = new clsDataBaseInfo(); dbContract.dsInfo = new DataSet(); sda.Fill(dbContract.dsInfo); sda.Dispose(); conn.Close(); conn.Dispose(); cmd.Dispose(); return dbContract; } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "clsMailDBService_EntsvcExecuteDataSet()", "clsMailDBService.xaml.cs"); return null; } }
clsDataBaseInfo clsMailDBService_EntsvcExecuteStoredProcedure(string spName, clsSqlParameterContract objSParam) { try { SqlConnection conn = new SqlConnection(VMuktiInfo.MainConnectionString); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = spName; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; if (objSParam != null && objSParam.objParam != null) { for (int paramCnt = 0; paramCnt < objSParam.objParam.Count; paramCnt++) { SqlParameter sp = new SqlParameter(); sp.ParameterName = (string)objSParam.objParam[paramCnt].PName; if (sp.Size != -1) { sp.Size = (int)objSParam.objParam[paramCnt].PSize; } sp.Value = (object)objSParam.objParam[paramCnt].PValue; string direction = (string)objSParam.objParam[paramCnt].Direction; string dbType = (string)objSParam.objParam[paramCnt].PDBType; //Enum.GetNames(typeof(SqlDbType)) switch (direction) { case "Input": { sp.Direction = ParameterDirection.Input; break; } case "InputOutput": { sp.Direction = ParameterDirection.InputOutput; break; } case "Output": { sp.Direction = ParameterDirection.Output; break; } case "ReturnValue": { sp.Direction = ParameterDirection.ReturnValue; break; } default: { break; } } switch (dbType) { case "VarChar": { sp.SqlDbType = SqlDbType.VarChar; break; } case "NVarChar": { sp.SqlDbType = SqlDbType.NVarChar; break; } case "Char": { sp.SqlDbType = SqlDbType.Char; break; } case "NChar": { sp.SqlDbType = SqlDbType.NChar; break; } case "Text": { sp.SqlDbType = SqlDbType.Text; break; } case "DateTime": { sp.SqlDbType = SqlDbType.DateTime; break; } case "Int": { sp.SqlDbType = SqlDbType.Int; break; } case "UniqueIdentifier": { sp.SqlDbType = SqlDbType.UniqueIdentifier; break; } case "Bit": { sp.SqlDbType = SqlDbType.Bit; break; } case "Float": { sp.SqlDbType = SqlDbType.Float; break; } case "Decimal": { sp.SqlDbType = SqlDbType.Decimal; break; } case "BigInt": { sp.SqlDbType = SqlDbType.BigInt; break; } default: { break; } } cmd.Parameters.Add(sp); } } SqlDataAdapter sda = new SqlDataAdapter(cmd); clsDataBaseInfo dbContract = new clsDataBaseInfo(); dbContract.dsInfo = new DataSet(); sda.Fill(dbContract.dsInfo); sda.Dispose(); conn.Close(); conn.Dispose(); cmd.Dispose(); return dbContract; } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "clsMailDBService_EntsvcExecuteStoredProcedure()", "clsMailDBService.xaml.cs"); return null; } }