WFA_psychometric_chart.Form_handler.InsertNodeInfoToDB C# (CSharp) Method

InsertNodeInfoToDB() public method

public InsertNodeInfoToDB ( int id, double xVal, double yVal, string source, string name, string label, Color colorValue, string showItemText ) : void
id int
xVal double
yVal double
source string
name string
label string
colorValue Color
showItemText string
return void
        public void InsertNodeInfoToDB(int id, double xVal, double yVal, string source, string name, string label, Color colorValue, string showItemText)
        {
            string tableName = currentNodeTableFromDB;

            string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string databaseFile = databasePath + @"\db_psychrometric_project.s3db";
            string connString = @"Data Source=" + databaseFile + ";Version=3;";

            using (SQLiteConnection connection = new SQLiteConnection(connString))
            {
                connection.Open();
                //SQLiteDataReader reader = null;
                string sql_string = "insert into "+tableName+"(id,xValue,yValue,source,name,label,colorValue,showItemText) VALUES(@id,@xVal,@yVal,@source,@name,@label,@colorVal,@text)";
                SQLiteCommand command = new SQLiteCommand(sql_string, connection);
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@id", id);
                command.Parameters.AddWithValue("@xVal", xVal.ToString());
                command.Parameters.AddWithValue("@yVal", yVal.ToString());
                command.Parameters.AddWithValue("@source", source);
                command.Parameters.AddWithValue("@name", name);
                command.Parameters.AddWithValue("@label", label);
                command.Parameters.AddWithValue("@colorVal", ColorTranslator.ToHtml(colorValue));
                command.Parameters.AddWithValue("@text",showItemText);

                //MessageBox.Show("selected value = " + cb_station_names.SelectedItem.ToString());
                command.ExecuteNonQuery();
            }
        }