I wanted to created a simple windows application for learning purpose. The objective was to simply have A database containing one Table, named "Table". The table would have a primary key called "id" and would be automatically incremented. Then the other field would be "name" of varchar type. I created the SQL database with visual studio 2005 as well as the rest of the project.
Then i would have simple form that has one listbox that would contain all the current listings in the database and then under that a textbox where u could add a name to the database, by filling in the textbox and clicking and add button that triggers an event to store it to the dataset then acutally updating the db.
So right now the listbox is populating correctly. And if you type a name into the box to add, it adds to the dataset correctly and populates in the listbox. The when i run the update method to actually store it in the db, i get a messagebox that says 1 row has been affected. (i put the message box in there for debugging purpose). So then i close the application and then hit F5 again to debug it again, and what names i added on the previous run did not store in the db.
If i go to the bin folder and run the actual exectuable, everything works perfect, i can add a name to the db, close the exe and re-run it and its there..... So i dont know if there is some kind of setting i would have to change to get the db to store while im in Visual Studio debugging. I have an example i found on the web that works either way, so i know its possible....Im just wondering if im missing a step. Heres my main form code:
Please let me know if you need anymore information
thanks
Abe
Then i would have simple form that has one listbox that would contain all the current listings in the database and then under that a textbox where u could add a name to the database, by filling in the textbox and clicking and add button that triggers an event to store it to the dataset then acutally updating the db.
So right now the listbox is populating correctly. And if you type a name into the box to add, it adds to the dataset correctly and populates in the listbox. The when i run the update method to actually store it in the db, i get a messagebox that says 1 row has been affected. (i put the message box in there for debugging purpose). So then i close the application and then hit F5 again to debug it again, and what names i added on the previous run did not store in the db.
If i go to the bin folder and run the actual exectuable, everything works perfect, i can add a name to the db, close the exe and re-run it and its there..... So i dont know if there is some kind of setting i would have to change to get the db to store while im in Visual Studio debugging. I have an example i found on the web that works either way, so i know its possible....Im just wondering if im missing a step. Heres my main form code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.tableTableAdapter.Fill(this.testDataSet.Table);
}
private void addButton_Click(object sender, EventArgs e)
{
testDataSet.TableRow n = testDataSet.Table.NewTableRow();
n.name = nameTextBox.Text;
testDataSet.Table.AddTableRow(n);
MessageBox.Show("Added Row Value: " + n.name);
int rE = tableTableAdapter.Update(n);
MessageBox.Show("Rows Affected: " + rE.ToString());
}
}
}
Please let me know if you need anymore information
thanks
Abe