# Linq insert statements



## mikeman22886 (May 11, 2009)

Im trying to create a program that tracks cards, basically you insert the player name, brand, year, and condition, along with the image and the linq statements i've tried haven't been working... I can query the database just fine, but if I want to insert a new row (basically saying a new card), the code shows no errors but after running and testing, the database doesn't show the row I added.....


private void SAVEbtn_Click(object sender, EventArgs e)
[//these are brackets
CardsSQLtoLinqDataContext db = new CardsSQLtoLinqDataContext();

Card car = new Card
[ //these are brackets
Player = textBox1.Text,
Brand = textBox2.Text,
Year = textBox3.Text,
Condition = comboBox1.SelectedText

};

label1.Text = textBox1.Text; //
label2.Text = textBox2.Text; //
label3.Text = textBox3.Text; //these are for testing purposes...


db.Cards.InsertOnSubmit(car);
db.SubmitChanges();

}

what am I doing wrong?

I've also tried

CardsSQLtoLinqDataContext db = new CardsSQLtoLinqDataContext();
Card cs = new Card();

cs.Player = textBox1.Text;
cs.Brand = textBox2.Text;
cs.Year = textBox3.Text;
cs.Condition = comboBox1.SelectedText;

db.Cards.InsertOnSubmit(cs);
db.SubmitChanges();

Im using Visual C# Express 2008.... also the square brackets are really curl brackets because the php page renders them into **


----------



## mikeman22886 (May 11, 2009)

nvm guys, I found the answer.


----------



## slyen (Jul 7, 2009)

I actually get the same problem as yours. May I know how you had fixed your problem of the linq statement? 

Thank You


----------



## slyen (Jul 7, 2009)

For mine, the problem is in the default value. Set the "Auto-Generated Value" to true ..

Things go okay.


----------



## mikeman22886 (May 11, 2009)

The solution was that the database was a local database, and the changes are not in the database you read from but the debug database (essentially a temp database for the complier to work on)...

Look in your debug folder for a database and open that in Visual studios and you will see the changes...


----------

