Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
AnswerRe: Refresh client datasets in an N-Tiered Application Pin
Member 279756116-Oct-08 2:07
Member 279756116-Oct-08 2:07 
GeneralRe: Refresh client datasets in an N-Tiered Application Pin
Wendelius16-Oct-08 8:48
mentorWendelius16-Oct-08 8:48 
GeneralRe: Refresh client datasets in an N-Tiered Application Pin
Member 279756129-Oct-08 1:25
Member 279756129-Oct-08 1:25 
QuestionSending low level keystroke messages Pin
ATM_Guy15-Oct-08 7:21
ATM_Guy15-Oct-08 7:21 
AnswerRe: Sending low level keystroke messages Pin
Dan Neely15-Oct-08 7:49
Dan Neely15-Oct-08 7:49 
AnswerRe: Sending low level keystroke messages Pin
Anthony Mushrow15-Oct-08 13:27
professionalAnthony Mushrow15-Oct-08 13:27 
Question(Late-)Binding of a run-time generated class Pin
Enrico77715-Oct-08 7:08
Enrico77715-Oct-08 7:08 
Questionsave to the database.help.sos with the code. Pin
sakis2415-Oct-08 7:00
sakis2415-Oct-08 7:00 
hi guys! what's up

here is my question..

hi!! i made an application and i want to save into my databae the datas from some textboxes. when i click the save button the datas are being normally or at least that's what i thought...
sometimes tha datas are being displayed sometimes not. for example, i run visual studio 2008 c# at 8 pm. and i can see the datas which i inserted before, i close studio,,, after a while i run again studiio and tha datas have gone....Frown


the code is correct..


Please help me guys, i really need your help.
sorry for my english





here is the comands
private void InitializeCommands()
{
//INSERT
dataAdapter.InsertCommand = conn.CreateCommand();
dataAdapter.InsertCommand.CommandText =
"SET IDENTITY_INSERT Producer ON insert into Producer(Pid,AFM,LastName,FirstName,City,ZipCode,Adress) values(@Pid,@AFM,@LastName,@FirstName,@City,@ZipCode,@Adress)";
AddParams(dataAdapter.InsertCommand, "Pid", "AFM", "LastName", "FirstName", "City", "ZipCode", "Adress");

//UPDATE
dataAdapter.UpdateCommand = conn.CreateCommand();
dataAdapter.UpdateCommand.CommandText =
"update Producer set AFM=@AFM, LastName=@LastName, FirstName=@FirstName, City=@City, ZipCode=@ZipCode, Adress=@Adress where Pid=@Pid ";
AddParams(dataAdapter.UpdateCommand, "Pid", "AFM", "LastName", "FirstName", "City", "ZipCode", "Adress");

//DELETE
dataAdapter.DeleteCommand = conn.CreateCommand();
dataAdapter.DeleteCommand.CommandText =
"delete from Producer where Pid = @Pid";
AddParams(dataAdapter.DeleteCommand, "Pid");
}



the add paremateres method
private void AddParams(SqlCommand cmd, params string[] cols)
{
foreach (string col in cols)
{
cmd.Parameters.Add("@" + col, SqlDbType.NVarChar, 0, col);

}

}


the insert button
private void btnAdd_Click(object sender, EventArgs e)
{

insertRec = true;
DataRow row = dt.NewRow();
dt.Rows.Add(row);
//MessageBox.Show(totalRec.ToString());
totalRec = dt.Rows.Count;
curRec = totalRec-1;
row["Pid"] = totalRec;

txtpid.Text = totalRec.ToString();
txtAFM.Text = "";
txtln.Text = "";
txtfn.Text = "";
txtCity.Text = "";
txtZip.Text = "";
txtAdr.Text = "";
btnSave.Enabled = true;
}






and the save button
private void btnSave_Click_1(object sender, EventArgs e)
{

DataRow row = dt.Rows[curRec];
//MessageBox.Show(totalRec.ToString());
//MessageBox.Show(curRec.ToString());

row.BeginEdit();
row["Pid"] = txtpid.Text;
row["AFM"] = txtAFM.Text;
row["LastName"] = txtln.Text;
row["FirstName"] = txtfn.Text;
row["City"] = txtCity.Text;
row["ZipCode"] = txtZip.Text;
row["Adress"] = txtAdr.Text;
row.EndEdit();



dataAdapter.Update(ds, "buffer");

ds.AcceptChanges();

CreateDir();

ToggleControls(true);
insertRec = !true;
}


i havevreated the dataset,dataadapter, the conection string and the datatable of cours
GeneralRe: save to the database.help.sos with the code. Pin
Wendelius15-Oct-08 7:56
mentorWendelius15-Oct-08 7:56 
QuestionVideo editing Pin
sana1715-Oct-08 6:56
sana1715-Oct-08 6:56 
AnswerRe: Video editing Pin
Thomas Stockwell15-Oct-08 8:26
professionalThomas Stockwell15-Oct-08 8:26 
GeneralRe: Video editing Pin
sana1715-Oct-08 8:49
sana1715-Oct-08 8:49 
Questionsave to the database.please help.sos with the code. Pin
sakis2415-Oct-08 6:40
sakis2415-Oct-08 6:40 
AnswerRe: save to the database.please help.sos with the code. Pin
Dave Kreskowiak15-Oct-08 7:49
mveDave Kreskowiak15-Oct-08 7:49 
GeneralRe: save to the database.please help.sos with the code. Pin
sakis2416-Oct-08 8:45
sakis2416-Oct-08 8:45 
Questiondithering Pin
afjepoifesahie15-Oct-08 6:38
afjepoifesahie15-Oct-08 6:38 
AnswerRe: dithering Pin
Dave Kreskowiak15-Oct-08 7:45
mveDave Kreskowiak15-Oct-08 7:45 
GeneralRe: dithering Pin
Anthony Mushrow15-Oct-08 7:50
professionalAnthony Mushrow15-Oct-08 7:50 
QuestionCheck for Table and Create Table if it is not found Pin
Planker15-Oct-08 5:43
Planker15-Oct-08 5:43 
AnswerRe: Check for Table and Create Table if it is not found Pin
Wendelius15-Oct-08 7:52
mentorWendelius15-Oct-08 7:52 
GeneralRe: Check for Table and Create Table if it is not found Pin
Planker15-Oct-08 8:17
Planker15-Oct-08 8:17 
GeneralRe: Check for Table and Create Table if it is not found Pin
Wendelius15-Oct-08 8:23
mentorWendelius15-Oct-08 8:23 
QuestionC# Code Help Pin
boiDev15-Oct-08 5:30
boiDev15-Oct-08 5:30 
AnswerRe: C# Code Help Pin
Pedram Behroozi15-Oct-08 5:54
Pedram Behroozi15-Oct-08 5:54 
GeneralRe: C# Code Help Pin
boiDev15-Oct-08 6:57
boiDev15-Oct-08 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.