Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ExcelOpenSQL;
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ExscelOpenSQL
- {
- class SQLOpen
- {
- /// <summary>
- /// удаление базы
- /// </summary>
- /// <param name="connectionString"></param>
- public void deleteOutputPrice(string connectionString)
- {
- using (SqlConnection con = new SqlConnection(connectionString))
- {
- con.Open();
- using (SqlCommand com = new SqlCommand("DELETE FROM OutputPrice", con))
- {
- com.ExecuteNonQuery();
- }
- }
- }
- /// <summary>
- /// добавление в базу
- /// </summary>
- /// <param name="list"></param>
- /// <param name="connectionString"></param>
- public void addDB(string [,] list, string connectionString)
- {
- using (SqlConnection con = new SqlConnection(connectionString))
- {
- ExcelFile ex = new ExcelFile();
- con.Open();
- for (int i = 0; i < list.GetLength(1); i++)
- {
- using (SqlCommand com = new SqlCommand("INSERT INTO Price(name, priceUSD, priceBYR) VALUES(@name, @priceUSD, @priceBYR)", con))
- {
- com.Parameters.AddWithValue("@name", list[1, i]);
- com.Parameters.AddWithValue("@priceUSD", list[2, i]);
- com.Parameters.AddWithValue("@priceBYR", list[3, i]);
- com.ExecuteNonQuery();
- com.Dispose();
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement