View Single Post
Old 06-09-2009, 09:14 AM   #1 (permalink)
mikeman22886
Registered User
 
Join Date: May 2009
Posts: 91
OS: win xp


Linq insert statements

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 **

Last edited by mikeman22886; 06-09-2009 at 09:20 AM.
mikeman22886 is offline   Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here