Witam
Mam 2 comboboxy, które wyświetlają mi listę atrybutów z innej bazy. po wybraniu atrybutu i naciśnięciu zapisz. Wywala mi błąd, że nie może zamienić comboboxa na string. Jak mogę zapisać wybraną zmienna do innej bazy,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Mamut_Zamówienie
{
public partial class Artykuł : Form
{
public Artykuł()
{
InitializeComponent();
}
private void art_Load(object sender, EventArgs e)
{
// TODO: Ten wiersz kodu wczytuje dane do tabeli 'zamówienieDataSet6.ART_PODGRUPA' . Możesz go przenieść lub usunąć.
this.aRT_PODGRUPATableAdapter1.Fill(this.zamówienieDataSet6.ART_PODGRUPA);
// TODO: Ten wiersz kodu wczytuje dane do tabeli 'zamówienieDataSet5.ART_GRUPA' . Możesz go przenieść lub usunąć.
this.aRT_GRUPATableAdapter1.Fill(this.zamówienieDataSet5.ART_GRUPA);
// TODO: Ten wiersz kodu wczytuje dane do tabeli 'zamówienieDataSet3.ART_GRUPA' . Możesz go przenieść lub usunąć.
this.aRT_GRUPATableAdapter.Fill(this.zamówienieDataSet3.ART_GRUPA);
// TODO: Ten wiersz kodu wczytuje dane do tabeli 'zamówienieDataSet2.ART_PODGRUPA' . Możesz go przenieść lub usunąć.
this.aRT_PODGRUPATableAdapter.Fill(this.zamówienieDataSet2.ART_PODGRUPA);
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cs = new SqlConnection("Data Source=(local); Initial Catalog=Zamówienie; Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand("INSERT INTO Artykuł VALUES (@Index, @Nazwa, @Grupa, @PodGrupa, @Jednostka, @MinStanMag, @MinZam)", cs);
da.InsertCommand.Parameters.Add("@Index", SqlDbType.VarChar).Value = box_index.Text;
da.InsertCommand.Parameters.Add("@Nazwa", SqlDbType.VarChar).Value = textBox_Nazwa.Text;
//combobox1//
da.InsertCommand.Parameters.Add("@Grupa", SqlDbType.Text).Value = grupa;
//combobox2//
da.InsertCommand.Parameters.Add("@PodGrupa", SqlDbType.Text).Value = podgrupa;
da.InsertCommand.Parameters.Add("@Jednostka", SqlDbType.VarChar).Value = jednostka;
da.InsertCommand.Parameters.Add("@MinStanMag", SqlDbType.VarChar).Value = minstanmag;
da.InsertCommand.Parameters.Add("@MinZam", SqlDbType.VarChar).Value = minzam;
cs.Open();
da.InsertCommand.ExecuteNonQuery();
cs.Close();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void box_index_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
private void minstanmag_TextChanged(object sender, EventArgs e)
{
}
private void minstanmag_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
private void minzam_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8 && ch != 46)
{
e.Handled = true;
}
}
private void grupa_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void podgrupa_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}