Mam taka tabelke w bazie danych (lokalnie w visual studio):
CREATE TABLE [dbo].[TPFORM] (
[id] INT IDENTITY (1, 1) NOT NULL,
[users_id] INT NOT NULL,
[name] VARCHAR (50) NOT NULL,
[surname] VARCHAR (50) NOT NULL,
[city] VARCHAR (50) NOT NULL,
[gender] INT NOT NULL,
[status_id] INT NOT NULL,
[age_id] INT NOT NULL,
[work] INT NOT NULL,
[other_account] INT NOT NULL,
[types_id] INT NOT NULL,
[banks_id] INT NOT NULL,
[unit] INT NOT NULL,
[mobile] INT NOT NULL,
[credit_card] INT NOT NULL,
[profit] INT NOT NULL
);
Normalnym insertem, dane się tam dodaja:
INSERT INTO [dbo].[TPFORM]([users_id],[name],[surname] ,[city],[gender],[status_id],[age_id],[work],[other_account],[types_id],[banks_id],[unit],[mobile],[credit_card],[profit])
VALUES (1,'f','f','f',1,1,1,1,1,1,1,1,1,1,1)
Dane dodają się też gdy sql jest w programie SQL SERVER, lecz gdy chce uzyc w samym visual ORMa do obłsugi inserta to te dane się nie insertuja. Skończyły mi się już pomysły co może być nie tak. Pomyślałem, jeszcze, że może być to problem z samym połączeniem (connection string), lecz na tej samej formatce działają mi selecty (zwracają prawidłowe dane).
using (db = new DataClassesDataContext())
{
TPFORM tp = new TPFORM();
tp.users_id = 1;
tp.name = "test1";
tp.surname = "test1";
tp.city = "test1";
tp.gender = 1;
tp.status_id = 1;
tp.age_id = 1;
tp.work = 1;
tp.other_account = 1;
tp.types_id = 1;
tp.banks_id = 1;
tp.unit = 1;
tp.mobile = 1;
tp.credit_card = 1;
tp.profit = 1;
db.TPFORM.InsertOnSubmit(tp);
try
{
db.SubmitChanges(); //to sie nie wykonuje
MessageBox.Show("OK!"); // zwraca OK
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Na debugu jest, że wszystkie wartości się przesyłają:
_age_id 1 int
_banks_id 1 int
_city "test1" string
_credit_card 1 int
_gender 1 int
_id 13 int
_mobile 1 int
_name "test1" string
_other_account 1 int
_profit 1 int
_status_id 1 int
_surname "test1" string
_types_id 1 int
_unit 1 int
_users_id 1 int
_work 1 int
...ale, nic nie wchodzi do bazy, o co tu chodzi?
Proszę o jakąś wskazówkę, gdzie może być błąd.