private static void procesoDB() { Console.WriteLine("Getting db connection..."); SqlConnection con = DBSQLServerUtils.GetDBConnection("MX17-MEX018012", "Prueba", "", ""); //Data Source = MX17 - MEX018012; Initial Catalog = Prueba; Integrated Security = True try { Console.WriteLine("Opening connection..."); con.Open(); Console.WriteLine("Connection successful!"); try { //QueryDNs(con); //CreateTempTable(con); //Query a bd temporal //usingTempVariableSQLTest(con); insertIntoPrueba(con); QueryaBDPrueba(con); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.WriteLine(e.StackTrace); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } Console.ReadLine(); }
public static SqlConnection GetDBConnection() { string datasource = @"192.168.205.135\SQLEXPRESS"; string database = "simplehr"; string username = "******"; string password = "******"; return(DBSQLServerUtils.GetDBConnection(datasource, database, username, password)); }
private static void procesoDBStoredProcedure() { //int vIMSI_TEMP, vDN_TEMP; Console.WriteLine("Getting db connection..."); SqlConnection con = DBSQLServerUtils.GetDBConnection("MX17-MEX018012", "Prueba", "", ""); //Data Source = MX17 - MEX018012; Initial Catalog = Prueba; Integrated Security = True try { Console.WriteLine("Opening connection..."); con.Open(); Console.WriteLine("Connection successful!"); try { SqlCommand cmd = new SqlCommand("SP_PruebaConsultaMultiple", con); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@param", Convert.ToInt32(Textbox1.Text)); cmd.Parameters.Add(new SqlParameter("@vDBVirtualMachineID", "Oscar")).Direction = ParameterDirection.Input; int vDN_TEMP = 0; cmd.Parameters.Add(new SqlParameter("@vDN_TEMP", SqlDbType.Int)).Direction = ParameterDirection.Output; int vIMSI_TEMP = 0; cmd.Parameters.Add(new SqlParameter("@vIMSI_TEMP", SqlDbType.Int)).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); vDN_TEMP = Convert.ToInt32(cmd.Parameters["@vDN_TEMP"].Value); vIMSI_TEMP = Convert.ToInt32(cmd.Parameters["@vIMSI_TEMP"].Value); //Console.WriteLine("Rows Affected: " + cmd.ExecuteNonQuery()); Console.WriteLine("Ejecutado: IMSI: " + vIMSI_TEMP + " DN: " + vDN_TEMP); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.WriteLine(e.StackTrace); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } finally { con.Close(); } //Console.ReadLine(); }
private static void updateRowWebService1_T4(int vimsi, string v) { Console.WriteLine("Getting db connection..."); SqlConnection con = DBSQLServerUtils.GetDBConnection("MX17-MEX018012", "Prueba", "", ""); //Data Source = MX17 - MEX018012; Initial Catalog = Prueba; Integrated Security = True try { Console.WriteLine("Opening connection..."); con.Open(); Console.WriteLine("Connection successful!"); try { string sql = ""; SqlCommand cmd = new SqlCommand(); cmd.Connection = con; sql = "UPDATE PruebaDeConsultaMultiple " + "SET RESULTADO_WS1 = 'EJECUTADO' WHERE" + " IMSI_TEMP = '" + vimsi + "' and MAQUINA_VIRTUAL = '" + v + "'"; cmd.CommandText = sql; //cmd.ExecuteNonQuery(); //cmd.ExecuteNonQuery(); Console.WriteLine("Rows Affected: " + cmd.ExecuteNonQuery()); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.WriteLine(e.StackTrace); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } finally { con.Close(); } //Console.ReadLine(); }