void initSQLTable(ProcSql proc) { DataTable inTable = SQLFunction.GetResultTable(proc.InTable); DataRow[] sqlRows = new DataRow[ResTable.Rows.Count]; DataRowCollection resRows = ResTable.Rows; for (int i = 0; i < resRows.Count; i++) { DataRow newRow = inTable.Rows.Add(); foreach (KeyValuePair <string, string> field in proc.inFields) { switch (field.Key.ToLower()) { case "ip": newRow[field.Key] = Scan.GetLocalIPByte(); break; case "row_id": newRow[field.Key] = i; break; default: newRow[field.Key] = resRows[i][field.Value]; break; } } sqlRows[i] = newRow; } SQLFunction.ExecuteNonQuery( String.Format("delete from {0} where IP = 0x{1}", proc.InTable, Scan.GetLocalIPAddress(true)) ); SQLFunction.BulkWrite(proc.InTable, sqlRows); }
private void button1_Click(object sender, EventArgs e) { const string message = "Save fields to DB?"; const string caption = "Form Closing"; var result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (funcInRow) { shema = String.Format("{0} \r\n({1})\r\n({2})\r\n({3})", tFunc.Text, ttabFields.Text, tInPar.Text, tOutPar.Text); } else { string query = String.Format( "update impFunc set tabFields = '{0}', inPar = '{1}', outPar = '{2}' where fnName = '{3}'", ttabFields.Text, tInPar.Text, tOutPar.Text, tFunc.Text); SQLFunction.ExecuteNonQuery(query); } } func = String.Format("{0} \r\n({1})\r\n({2})\r\n({3})", tFunc.Text, tStrTabFields.Text, tStrInPar.Text, tStrOutPar.Text); Close(); }
private void ClearSqlData() { SQLFunction.ExecuteNonQuery( String.Format("delete from {0} where IP = 0x{1} ", SQLTableName, Scan.GetLocalIPAddress(true))); }
public void dropTemplate() { string query = $@"IF OBJECT_ID('tempdb..{tableName}') IS NOT NULL DROP TABLE {tableName}"; SQLFunction.ExecuteNonQuery(query, false, conn); }
public void createTempTable() { SQLFunction.ExecuteNonQuery(createTableSctipt, false, conn); }