private string Foo(int longIndexName, DataSet ds) { string Key = ds.Tables[0].Rows[0]["Key"].ToString(); if (!string.IsNullOrEmpty(Key) && Key != "SAMP") { try { ds.Tables[0].Rows[0]["Key"] = Encoding.ASCII.GetString(PerfFormOp(Convert.FromBase64String(Key), longIndexName)); ds.AcceptChanges(); } catch (Exception ex) { Logging.Post(ex); } } return ds.GetXml(); }
public int BulkUploadAlert(int TenantID, int CreatedBy, DataSet DataSetCSV) { int uploadCount = 0; XmlDocument xmlDoc = new XmlDocument(); try { if (DataSetCSV != null && DataSetCSV.Tables.Count > 0) { if (DataSetCSV.Tables[0] != null && DataSetCSV.Tables[0].Rows.Count > 0) { xmlDoc.LoadXml(DataSetCSV.GetXml()); conn = Db.Connection; MySqlCommand cmd = new MySqlCommand("", conn); cmd.Connection = conn; cmd.Parameters.AddWithValue("@_xml_content", xmlDoc.InnerXml); cmd.Parameters.AddWithValue("@_node", Xpath); cmd.Parameters.AddWithValue("@_tenantID", TenantID); cmd.Parameters.AddWithValue("@_createdBy", CreatedBy); cmd.CommandType = CommandType.StoredProcedure; uploadCount = cmd.ExecuteNonQuery(); } } } catch (Exception ex) { string message = Convert.ToString(ex.InnerException); throw ex; } finally { if (DataSetCSV != null) { DataSetCSV.Dispose(); } } return(uploadCount); }
/// <summary> /// Execute XmlReader with complete Command /// </summary> /// <param name="command">SQLite Command</param> /// <returns>XmlReader</returns> public static XmlReader ExecuteXmlReader(IDbCommand command) { // open the connection if necessary, but make sure we // know to close it when we’re done. if (command.Connection.State != ConnectionState.Open) { command.Connection.Open(); } // get a data adapter SQLiteDataAdapter da = new SQLiteDataAdapter((SQLiteCommand)command); DataSet ds = new DataSet(); // fill the data set, and return the schema information da.MissingSchemaAction = MissingSchemaAction.AddWithKey; da.Fill(ds); // convert our dataset to XML StringReader stream = new StringReader(ds.GetXml()); command.Connection.Close(); // convert our stream of text to an XmlReader return(new XmlTextReader(stream)); }
// ---------------------------------------------------- // method to return an XML document (as a String) containing // a full list of supplier details from database public String GetSuppliersXml(Boolean IncludeSchema) { // declare a String containing the stored procedure name String strQuery = "GetSupplierList"; // create a new Connection object using connection string OleDbConnection objConnect = new OleDbConnection(m_ConnectString); // create new DataAdapter using stored proc name and Connection OleDbDataAdapter objAdapter = new OleDbDataAdapter(strQuery, objConnect); // create a new DataSet object to hold the results DataSet objDataSet = new DataSet(); // declare an empty String to hold the results String strXml = String.Empty; try { // get the data into a table named "Suppliers" in the DataSet objAdapter.Fill(objDataSet, "Suppliers"); // get schema if ( specif (ied in optional method parameter if (IncludeSchema == true) { strXml = objDataSet.GetXmlSchema() + (char)13 + (char)10 + (char)13 + (char)10; } // get XML data and append to String strXml += objDataSet.GetXml(); // return the XML string to the calling routine return(strXml); } catch (Exception objErr) { throw (objErr); } }
public static XmlDocument Serialize(object objObject) { XmlSerializer objXmlSerializer = new XmlSerializer(objObject.GetType()); StringBuilder objStringBuilder = new StringBuilder(); TextWriter objTextWriter = new StringWriter(objStringBuilder); objXmlSerializer.Serialize(objTextWriter, objObject); StringReader objStringReader = new StringReader(objTextWriter.ToString()); DataSet objDataSet = new DataSet(); objDataSet.ReadXml(objStringReader); XmlDocument xmlSerializedObject = new XmlDocument(); xmlSerializedObject.LoadXml(objDataSet.GetXml()); return(xmlSerializedObject); }
public List <ThamSoBaoCao> GetParameters() { if (!Validation()) { return(null); } List <ThamSoBaoCao> listThamSoBaoCao = new List <ThamSoBaoCao>(); listThamSoBaoCao.Add(new ThamSoBaoCao("@MaChiNhanh", maChiNhanh, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@MaPhongGD", maPhongGD, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@TenChiNhanh", tenChiNhanh, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@ThangDuTru", thangDuTru, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@NgayBaoCao", thangBaoCao, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@TyLe", tyLe.ToString(), ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@UserName", ClientInformation.TenDangNhap, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); DataTable dt = null; DataSet ds = new DataSet(); DataView drvGiaTri = grdSoTien.ItemsSource as DataView; dt = drvGiaTri.Table.Clone(); foreach (DataRowView drv in drvGiaTri) { dt.Rows.Add(drv.Row.ItemArray); } drvGiaTri = grdThuTien.ItemsSource as DataView; foreach (DataRowView drv in drvGiaTri) { dt.Rows.Add(drv.Row.ItemArray); } drvGiaTri = grdChiTien.ItemsSource as DataView; foreach (DataRowView drv in drvGiaTri) { dt.Rows.Add(drv.Row.ItemArray); } ds.Tables.Add(dt); listThamSoBaoCao.Add(new ThamSoBaoCao("P_Result", ds.GetXml(), ApplicationConstant.LoaiThamSoBaoCao.GUI.layGiaTri())); return(listThamSoBaoCao); }
/// <summary> /// Transforms a DataSet via XSLT. /// </summary> /// <param name="ds">DataSet of results.</param> /// <param name="xsltFileName">XSLT file name.</param> /// <param name="xsltArgs">XSLT arguments.</param> /// <param name="rootNodeName">XML root node (optional, defaults to 'root').</param> /// <returns>XSLT output.</returns> public string TransformDataSet(DataSet ds, string xsltFileName, XsltArgumentList xsltArgs, string rootNodeName) { // if we weren't given a root node name, we have to call it something, so default/'root' if (string.IsNullOrEmpty(rootNodeName)) { rootNodeName = DefaultRootNodeName; } // create a return writer buffer for holding HTML using (var xsltOutput = new StringWriter(CultureInfo.InvariantCulture)) { ds.DataSetName = rootNodeName; using (var xmlSr = new StringReader(ds.GetXml())) { XPathDocument xpathDoc = new XPathDocument(xmlSr); // setup our Xsl compiled transform XslCompiledTransform xsl = new XslCompiledTransform(false); // allow document() XsltSettings xsltSettings = new XsltSettings(true, true); xsl.Load(xsltFileName, xsltSettings, new XmlUrlResolver()); // setup xslt args if null if (xsltArgs == null) { xsltArgs = new XsltArgumentList(); } // do the transform xsl.Transform(xpathDoc, xsltArgs, xsltOutput); // return HTML return(xsltOutput.ToString()); } } }
public DataSet EncryptDataSet(DataSet ds, string fileName, string folderPath = null) { if (!Directory.Exists(folderPath + "data")) { Directory.CreateDirectory(folderPath + "data"); } using (FileStream fs = new FileStream(fileName + ".bin", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (CryptoStream cs = new CryptoStream(fs, des.CreateEncryptor(), CryptoStreamMode.Write)) { // Encrypt the DataSet to the file: using (StreamWriter sw = new StreamWriter(cs)) { sw.Write(ds.GetXml()); } } } // Now write the DataSet schema to disk: if (fileName.ToLower().Contains("pattern")) { ds.WriteXmlSchema(folderPath + "data\\main.xsd"); } else { if (folderPath == null) { ds.WriteXmlSchema("data\\sub.xsd"); } else { ds.WriteXmlSchema(folderPath + "data\\sub.xsd"); } } return(ds); }
private void btnGuardar_Click(object sender, EventArgs e) { //logica de guardado if (ValidaGuardar()) { return; } DataTable TablaApuesta = ConvertToDataTable <ConfiguraApuesta>(_ListaConfiguracion); DataSet ds = new DataSet("dsConfiguracionApuesta"); ds.Tables.Add(TablaApuesta); string XML = ds.GetXml(); int idUsuario = VarGlobal.SysUser.idUsuario; DateTime dFechaSys = VarGlobal.dFechaSys; string Rtpa = ""; if (_Accion.Equals("N")) { Rtpa = _Ronda.GuardaNuevaConfiguracion(XML, idUsuario, dFechaSys); } else if (_Accion.Equals("A")) { Rtpa = _Ronda.ActualizaConfiguracion(XML, idUsuario, dFechaSys); } MyMessageBox.Show(Rtpa, "Guarda configuracion de apuestas", MessageBoxButtons.OK, MessageBoxIcon.Information); _Accion = ""; HabilitaControles(false); LimpiaControles(); dtgDetalle.Enabled = true; chcActivo.Enabled = true; chcActivo.Checked = false; CargarConfiguracion(); }
/// <summary> /// Executes the application. /// </summary> static public void Main(string[] args) { //setup our Service configuration IServiceProvider serviceProvider = ServiceCofigurator.GetServiceProvider(); var logger = serviceProvider.GetService <ILoggerFactory>().CreateLogger <Program>(); logger.LogInformation("Starting application"); //do the actual work here using (IFooService foo = serviceProvider.GetService <IFooService>()) { logger.LogInformation("FooService first run"); foo.DoFileService(); foo.DoRegexService(); } //do the actual work here using (IFooService foo = serviceProvider.GetService <IFooService>()) { logger.LogInformation("FooService second run"); foo.DoFileService(); foo.DoRegexService(); foo.DoTupleService(); } //do the actual work here using (ICarService carService = serviceProvider.GetService <ICarService>()) { carService.CreateCarport(); carService.SellCar(1, "Mike Coley"); DataSet ds = carService.ListCars(); logger.LogInformation("DataSet {0}", ds.GetXml()); } logger.LogInformation("Finishing application"); }
private void XmlToSqlExec2() { String xml = XmlToSqlCmd_v2.getPostContent(); List <XmlToList> list = XmlToSqlCmd_v2.ConvertXmlToSqlCommand(xml); DataSet ds = new DataSet("data"); foreach (XmlToList xtl in list) { try { DataTable table = DBHelper.DataTableDBExecuteSqlCommand(xtl.SQL, xtl.PARS); if (!String.IsNullOrEmpty(xtl.TABLENAME)) { table.TableName = xtl.TABLENAME; } ds.Tables.Add(table); } catch (SqlException exp) { //exp.Message; HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; HttpContext.Current.Response.ContentType = "text/xml"; HttpContext.Current.Response.Write("<sqlerr><![CDATA[" + exp.Message + "]]></sqlerr>"); return; //throw; } } HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; HttpContext.Current.Response.ContentType = "text/xml"; string XmlSchema = ds.GetXmlSchema(); string Xml = ds.GetXml(); HttpContext.Current.Response.Write(XmlSchema + "<xmlsplit></xmlsplit>" + Xml); }
public ResponseModel Attachment_C(string filename, string fileformat, long filesize, out string resultXML) { var responseModel = new ResponseModel(); string return_resultXML = null; string return_string = string.Empty; resultXML = String.Empty; try { /*throw new Exception("test_exception");*/ DataSet ds = this.Attachment_CRD(CRUD.C, null, filename, fileformat, filesize, out return_string); if (ds != null) { ds.DataSetName = XMLCommonUtil.DATASET_NAME; ds.Tables[0].TableName = XMLCommonUtil.TABLE_NAME; return_resultXML = ds.GetXml(); if (ds.Tables.Count > 0) { ds.Tables[0].TableName = "item"; responseModel.Values.Add("item", ds.Tables[0].ToDictionaryEnumerable()); } } } catch (Exception ex) { //throw ex; //return_string = xmlCommonUtil.returnErrorMSGXML("Attachment_C", ex); throw new ServiceException("Attachment_C", ex); } //resultXML = return_resultXML; //return return_string; return(responseModel); }
public void CreateOfflineCustomerOrderAssociation(DataTable OrderAssociates, int userId, int orderId) { Database db; DbCommand cmdOfflineBondTransact; try { DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt = OrderAssociates.Copy(); ds.Tables.Add(dt); String sb; sb = ds.GetXml().ToString(); db = DatabaseFactory.CreateDatabase("wealtherp"); cmdOfflineBondTransact = db.GetStoredProcCommand("SPROC_OFF_CreateCustomerOrderAssociates"); db.AddInParameter(cmdOfflineBondTransact, "@xmlBondsOrder", DbType.Xml, sb); db.AddInParameter(cmdOfflineBondTransact, "@UserId", DbType.Int32, userId); db.AddInParameter(cmdOfflineBondTransact, "@Order_Id", DbType.Int32, orderId); db.ExecuteNonQuery(cmdOfflineBondTransact); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "OnlineBondOrderDao.cs:CreateCustomerOrderAssociation(DataTable OrderAssociates, int userId,int orderId)"); object[] objects = new object[1]; objects[0] = OrderAssociates; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } }
public static string DateDisplay(Int32 teamid) { DateTime datestart, dateend; SystemObjects.TableF _tablef = new SystemObjects.TableF(); _tablef.TeamID = teamid; DataSet ds = new DataSet(); try { DataTable dt = new DataTable(); dt = _tablef.displayRatingsDate(); DataTable dtdate = new DataTable(); dtdate.Columns.Add("Dates"); dtdate.Rows.Add("Please select Month - Year..."); dateend = DateTime.Now.AddMonths(-1); if (dt.Rows.Count.Equals(0)) { datestart = DateTime.Now.AddYears(-3); } else { datestart = Convert.ToDateTime(dt.Rows[0]["RateDateMax"].ToString()); } while (datestart <= dateend) { DateTime datestart_ = Convert.ToDateTime(datestart.Month.ToString() + "/01/" + datestart.Year.ToString()); dtdate.Rows.Add(String.Format("{0:MMMM - yyyy}", datestart_)); datestart = datestart.AddMonths(1); } ds.Tables.Add(dtdate); } catch (Exception ex) { } return(ds.GetXml()); }
public bool UpdateNCDDetails(int orderid, int userid, DataTable dtOrderDetails, string brokerCode, int agentId, OnlineBondOrderVo OnlineBondOrderVo, int EmpId) { Microsoft.Practices.EnterpriseLibrary.Data.Database db; DbCommand UpdateNCDDetailscmd; bool bResult = false; DataSet dsUpdateUpdateNCDDetails = new DataSet(); try { dsUpdateUpdateNCDDetails.Tables.Add(dtOrderDetails.Copy()); dsUpdateUpdateNCDDetails.DataSetName = "dtOrderDetailseDS"; dsUpdateUpdateNCDDetails.Tables[0].TableName = "dtOrderDetailsDT"; db = DatabaseFactory.CreateDatabase("wealtherp"); UpdateNCDDetailscmd = db.GetStoredProcCommand("SPROC_UpdateNCDOrder"); db.AddInParameter(UpdateNCDDetailscmd, "@xmlBondsOrder", DbType.Xml, dsUpdateUpdateNCDDetails.GetXml().ToString()); db.AddInParameter(UpdateNCDDetailscmd, "@orderId", DbType.Int32, orderid); db.AddInParameter(UpdateNCDDetailscmd, "@UserId", DbType.Int32, userid); db.AddInParameter(UpdateNCDDetailscmd, "@brokerCode", DbType.String, brokerCode); db.AddInParameter(UpdateNCDDetailscmd, "@AgentId", DbType.Int32, agentId); db.AddInParameter(UpdateNCDDetailscmd, "@CustomerName", DbType.String, OnlineBondOrderVo.CustomerName); db.AddInParameter(UpdateNCDDetailscmd, "@CustomerPAN", DbType.String, OnlineBondOrderVo.PanNo); db.AddInParameter(UpdateNCDDetailscmd, "@CustomerType", DbType.String, OnlineBondOrderVo.CustomerType); //db.AddInParameter(UpdateNCDDetailscmd, "@CustomerSubTypeId", DbType.Int32, OnlineBondOrderVo.CustomerSubTypeId); db.AddInParameter(UpdateNCDDetailscmd, "@DematBeneficiaryAccountNum", DbType.String, OnlineBondOrderVo.DematBeneficiaryAccountNum); db.AddInParameter(UpdateNCDDetailscmd, "@DematDepositoryName", DbType.String, OnlineBondOrderVo.DematDepositoryName); db.AddInParameter(UpdateNCDDetailscmd, "@DematDPId", DbType.String, OnlineBondOrderVo.DematDPId); db.AddInParameter(UpdateNCDDetailscmd, "@AID_Sequence", DbType.Int32, OnlineBondOrderVo.PFISM_SchemeId); db.AddInParameter(UpdateNCDDetailscmd, "@customerbankAccId", DbType.Int64, OnlineBondOrderVo.BankAccountNo); db.AddInParameter(UpdateNCDDetailscmd, "@EmpId", DbType.Int32, EmpId); db.ExecuteNonQuery(UpdateNCDDetailscmd); bResult = true; } catch (BaseApplicationException Ex) { throw Ex; } return(bResult); }
public static string CollectionXml <T>(this ICollection <T> list, string DatasetName, string DataTableName) { Type elementType = typeof(T); DataSet ds = new DataSet(); DataTable t = new DataTable(); if (list != null) { if (list.Count > 0) { ds.DataSetName = DatasetName; t.TableName = DataTableName; ds.Tables.Add(t); //add a column to table for each public property on T foreach (var propInfo in elementType.GetProperties()) { Type ColType = Nullable.GetUnderlyingType(propInfo.PropertyType) ?? propInfo.PropertyType; t.Columns.Add(propInfo.Name, ColType); } //go through each property on T and add each value to the table foreach (T item in list) { DataRow row = t.NewRow(); foreach (var propInfo in elementType.GetProperties()) { row[propInfo.Name] = propInfo.GetValue(item, null) ?? DBNull.Value; } t.Rows.Add(row); } } } return(ds.GetXml()); }
public string SearchCouponcode(PropCouponCode objCouponCode) { SqlCommand cmd = new SqlCommand("proc_CouponCodeForRegistration", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "Apply"); cmd.Parameters.AddWithValue("@CouponCode", objCouponCode.CouponCode); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "ccsign"); objCon.Con.Close(); return(ds.GetXml()); }
/// <summary> /// Ecriture du fichier au format DataSet /// </summary> /// <param name="fileName">nom pour le fichier</param> public void SaveXmlData(string fileName) { XmlWriter xw = XmlWriter.Create(fileName, settings); xmlDataDoc.WriteTo(xw); xw.Flush(); xw.Close(); StringWriter sw = new StringWriter(); sw.Write(dataSet.GetXml()); sw.Flush(); sw.Close(); StreamWriter outfile = new StreamWriter(fileName + ".2"); outfile.Write(sw); outfile.Flush(); outfile.Close(); StringWriter sw2 = new StringWriter(); sw2.Write(dataSet.GetXmlSchema()); sw2.Flush(); sw2.Close(); StreamWriter outfile2 = new StreamWriter(fileName + ".xsd"); outfile2.Write(sw2); outfile2.Flush(); outfile2.Close(); }
public string CountTotalAllAdvts(int associateID) { SqlCommand cmd = new SqlCommand("proc_AllAssociateCategories", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@associateID", associateID); cmd.Parameters.AddWithValue("@action", "CountAllAdvts"); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "TotalAllAds"); objCon.Con.Close(); return(ds.GetXml()); }
/// <summary> /// Execute a SQLiteCommand (that returns a resultset) against the specified SQLiteTransaction /// using the provided parameters. /// </summary> /// <remarks> /// e.g.: /// XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders", new SQLiteParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">a valid SQLiteTransaction</param> /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> /// <param name="commandText">the stored procedure name or T-SQL command using "FOR XML AUTO"</param> /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> /// <returns>an XmlReader containing the resultset generated by the command</returns> public static XmlReader ExecuteXmlReader(SQLiteTransaction transaction, CommandType commandType, string commandText, params SQLiteParameter[] commandParameters) { //create a command and prepare it for execution SQLiteCommand cmd = new SQLiteCommand(); PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters); // get a data adapter SQLiteDataAdapter da = new SQLiteDataAdapter((SQLiteCommand)cmd); DataSet ds = new DataSet(); // fill the data set, and return the schema information da.MissingSchemaAction = MissingSchemaAction.AddWithKey; da.Fill(ds); // convert our dataset to XML StringReader stream = new StringReader(ds.GetXml()); // convert our stream of text to an XmlReader XmlReader retval = new XmlTextReader(stream); // detach the SqlParameters from the command object, so they can be used again. cmd.Parameters.Clear(); return(retval); }
public static string GetCustomers() { string query = "Select Product_Id, Product_Name, Product_Description, Product_Category, Product_Price, Product_Quantity from Items"; String cs = ConfigurationManager.ConnectionStrings["WebShopDB"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { SqlCommand cmd = new SqlCommand(); sda.SelectCommand = cmd; cmd.Connection = con; cmd.CommandText = query; using (DataSet ds = new DataSet()) { sda.Fill(ds); return(ds.GetXml()); } } } }
public static void exportUczy() { var Uczy = ""; DataSet ds = new DataSet("Uczy"); string table = "Uczy"; connection.Open(); var query = "SELECT * FROM " + table; OracleCommand cmd = new OracleCommand(query, connection); OracleDataAdapter da = new OracleDataAdapter(cmd); da.TableMappings.Add("Table", "Uczy"); da.Fill(ds); Uczy += ds.GetXml(); connection.Close(); File.WriteAllText("D://uczy.xml", Uczy); }
public string SelectJobType(int flag) { SqlCommand cmd = new SqlCommand("proc_JobType", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "View"); cmd.Parameters.AddWithValue("@flagValue", flag); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "JobType"); objCon.Con.Close(); return(ds.GetXml()); }
public static void exportSale_zaj() { var sala_zajeciowa = ""; DataSet ds = new DataSet("sale_zajeciowe"); string table = "Sala_zajeciowa"; connection.Open(); var query = "SELECT * FROM " + table; OracleCommand cmd = new OracleCommand(query, connection); OracleDataAdapter da = new OracleDataAdapter(cmd); da.TableMappings.Add("Table", "Sala_zajeciowa"); da.Fill(ds); sala_zajeciowa += ds.GetXml(); connection.Close(); File.WriteAllText("D://sala_zajeciowa.xml", sala_zajeciowa); }
static void Main() { // Create two DataTable instances. DataTable table1 = new DataTable("patients"); table1.Columns.Add("name"); table1.Columns.Add("id"); table1.Rows.Add("sam", 1); table1.Rows.Add("mark", 2); DataTable table2 = new DataTable("medications"); table2.Columns.Add("id"); table2.Columns.Add("medication"); table2.Rows.Add(1, "atenolol"); table2.Rows.Add(2, "amoxicillin"); // Create a DataSet and put both tables in it. DataSet set = new DataSet("office"); set.Tables.Add(table1); set.Tables.Add(table2); // Visualize DataSet. Console.WriteLine(set.GetXml()); }
/// <summary> /// This Method will get data of associate and advertisements for whome consumer contated before /// </summary> /// <param name="ConsumerID"></param> /// <returns></returns> public string ViewAssociateContactedDetail(int ConsumerID) { SqlCommand cmd = new SqlCommand("proc_SaveAdvertisements", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@action", "ViewContactAssociateData"); cmd.Parameters.AddWithValue("@ConsumerID", ConsumerID); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "ViewAssociateContactedDetails"); objCon.Con.Close(); return(ds.GetXml()); }
public string SelectHomePageAdvertisement(int subCategoryID) { SqlCommand cmd = new SqlCommand("proc_DisplayAdvertisements", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "HomePage"); cmd.Parameters.AddWithValue("@subCategoryID", subCategoryID); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "HViewAdvertisments"); objCon.Con.Close(); return(ds.GetXml()); }
protected XmlElement DocDuLieuTuCSDL() { XmlElement DuLieuXml = null; DataSet DuLieuADO = new DataSet(); DuLieuADO.DataSetName = TenDuLieuLuuTru; //DocBang("GIOI_TINH", "", DuLieuADO); //DocBang("NGOAI_NGU", "", DuLieuADO); //DocBang("LOAI_DICH_VU", "", DuLieuADO); //DocBang("CONG_TY", "", DuLieuADO); //DocBang("CHI_NHANH", "", DuLieuADO); //DocBang("DON_VI", "", DuLieuADO); //DocBang("NHAN_VIEN", "", DuLieuADO); DocBang("TIEPTAN_DANGNHAP", "", DuLieuADO); string ChuoiXml = DuLieuADO.GetXml(); XmlDocument TaiLieu = new XmlDocument(); TaiLieu.LoadXml(ChuoiXml); DuLieuXml = TaiLieu.DocumentElement; return(DuLieuXml); }
/// <summary> /// This method is used to show features about the particular advertisment /// </summary> /// <param name="advertismentID"></param> /// <returns></returns> public string ShowFeaturesAdvertisment(int advertismentID) { SqlCommand cmd = new SqlCommand("proc_DisplayAdvertisements", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "ShowAdvertisementFeatures"); cmd.Parameters.AddWithValue("@advertisementID", advertismentID); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "FullDetailsAdvertisments"); objCon.Con.Close(); return(ds.GetXml()); }
public string GetAllAssignedItems() { Guid userId = Guid.Empty; SqlDatabase db = DatabaseFactory.CreateDatabase() as SqlDatabase; if (db == null) { throw new Exception("Do poprawnego dzia³ania wymagany jest SQL Server 2005!"); } DbCommand cmd = db.GetStoredProcCommand("[Akcje].[listaOczekujacychZadan]", userId); cmd.CommandTimeout = 600; DataSet dsZadania = db.ExecuteDataSet(cmd); if (dsZadania.Tables.Count > 0) { dsZadania.DataSetName = "zadania"; dsZadania.Tables[0].TableName = "zadanie"; return(dsZadania.GetXml()); } return(string.Empty); }
//Activate This Construntor to log All To Standard output //public TestClass():base(true){} //Activate this constructor to log Failures to a log file //public TestClass(System.IO.TextWriter tw):base(tw, false){} //Activate this constructor to log All to a log file //public TestClass(System.IO.TextWriter tw):base(tw, true){} //BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES public void run() { Exception exp = null; DataSet ds1, ds2 = new DataSet(); ds2.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable()); ds1 = ds2.Copy(); //create changes ds2.Tables[0].Rows[0][0] = "70"; ds2.Tables[0].Rows[1].Delete(); ds2.Tables[0].Rows.Add(new object[] { 9, "string1", "string2" }); try { BeginCase("RejectChanges"); ds2.RejectChanges(); Compare(ds1.GetXml(), ds2.GetXml()); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
public void Copy() { DataSet ds = new DataSet(), dsTarget = null; ds.Tables.Add(DataProvider.CreateParentDataTable()); ds.Tables.Add(DataProvider.CreateChildDataTable()); ds.Relations.Add(new DataRelation("myRelation", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0])); ds.Tables[0].Rows.Add(new object[] { 9, "", "" }); ds.Tables[1].Columns[2].ReadOnly = true; ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns[0], ds.Tables[0].Columns[1] }; //copy data and schema // Copy 1 dsTarget = ds.Copy(); //Assert.Equal(ds.GetXmlSchema(), dsTarget.GetXmlSchema() ); //using my function because GetXmlSchema in not implemented in java Assert.Equal(DataProvider.GetDSSchema(ds), DataProvider.GetDSSchema(dsTarget)); // Copy 2 Assert.Equal(true, dsTarget.GetXml() == ds.GetXml()); }
/// <summary> /// Execute XmlReader with complete Command /// </summary> /// <param name="command">SQLite Command</param> /// <returns>XmlReader</returns> public static XmlReader ExecuteXmlReader(IDbCommand command) { // open the connection if necessary, but make sure we // know to close it when we�re done. if (command.Connection.State != ConnectionState.Open) { command.Connection.Open(); } // get a data adapter SQLiteDataAdapter da = new SQLiteDataAdapter((SQLiteCommand)command); DataSet ds = new DataSet(); // fill the data set, and return the schema information da.MissingSchemaAction = MissingSchemaAction.AddWithKey; da.Fill(ds); // convert our dataset to XML StringReader stream = new StringReader(ds.GetXml()); command.Connection.Close(); // convert our stream of text to an XmlReader return new XmlTextReader(stream); }
//��������ת�� //��ʵ���ǽ�dataset�����ݶ�����xml�ļ���Ȼ������� public static DataSet ISO8859_GB2312(DataSet ds) { #region string xml; xml = ds.GetXml(); ds.Clear(); //�����ַ��� System.Text.Encoding iso8859, gb2312; //iso8859 iso8859 = System.Text.Encoding.GetEncoding("iso8859-1"); //����2312 gb2312 = System.Text.Encoding.GetEncoding("gb2312"); byte[] bt; bt = iso8859.GetBytes(xml); xml = gb2312.GetString(bt); ds.ReadXml(new System.IO.StringReader(xml)); return ds; #endregion }
public void GetXml() { var ds = new DataSet(); ds.Namespace = "namespace"; //if we don't add namespace the test will fail because GH (by design) always add namespace DataTable dt = DataProvider.CreateParentDataTable(); dt.Clear(); dt.Rows.Add(new object[] { 1, "Value1", "Value2" }); dt.Rows.Add(new object[] { 2, "Value3", "Value4" }); dt.Rows.Add(new object[] { 3, "Value5", "Value5" }); StringBuilder resultXML = new StringBuilder(); resultXML.Append("<" + ds.DataSetName + "xmlns=\"namespace\">"); resultXML.Append("<Parent>"); resultXML.Append("<ParentId>1</ParentId>"); resultXML.Append("<String1>Value1</String1>"); resultXML.Append("<String2>Value2</String2>"); resultXML.Append("</Parent>"); resultXML.Append("<Parent>"); resultXML.Append("<ParentId>2</ParentId>"); resultXML.Append("<String1>Value3</String1>"); resultXML.Append("<String2>Value4</String2>"); resultXML.Append("</Parent>"); resultXML.Append("<Parent>"); resultXML.Append("<ParentId>3</ParentId>"); resultXML.Append("<String1>Value5</String1>"); resultXML.Append("<String2>Value5</String2>"); resultXML.Append("</Parent>"); resultXML.Append("</" + ds.DataSetName + ">"); ds.Tables.Add(dt); string strXML = ds.GetXml(); strXML = strXML.Replace(" ", ""); strXML = strXML.Replace("\t", ""); strXML = strXML.Replace("\n", ""); strXML = strXML.Replace("\r", ""); // GetXml Assert.Equal(resultXML.ToString(), strXML); }
public void RejectChanges() { DataSet ds1, ds2 = new DataSet(); ds2.Tables.Add(DataProvider.CreateParentDataTable()); ds1 = ds2.Copy(); //create changes ds2.Tables[0].Rows[0][0] = "70"; ds2.Tables[0].Rows[1].Delete(); ds2.Tables[0].Rows.Add(new object[] { 9, "string1", "string2" }); // RejectChanges ds2.RejectChanges(); Assert.Equal(ds2.GetXml(), ds1.GetXml()); }