473,672 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update table using bound text box

gj
Hi,

I'm trying to update a sql database from a web form using text boxes.
I'm trying to learn C# on my own so I am at a complete loss. I created
my sql connection, data adapter, dataset and data view in the visual
studio designer. I'm trying to keep a history of the record so instead
of editing the record I insert a new record with my changes. Instead
of the changes, it inserts the orginal record. Below is the part of
the code. Any help would be appreiated.

else if (txtTask.Text.T rim() == "1")
{
//assign values to variables
valName = txtName.Text.To String();
valStatus = txtStatus.Text. ToString();
valQuestionsPer Page = short.Parse(txt QuestionsPerPag e.Text);
valRetakeOption = int.Parse(drpRe takeOption.Sele ctedValue);
valPassGrade = short.Parse(txt PassGrade.Text) ;
valAuthor = txtAuthor.Text. ToString();
valUserID = "jongay";
valSortType = int.Parse(drpSo rtType.Selected Value);
valNotifyOption s = int.Parse(drpNo tifyOptions.Sel ectedValue);
valGradeScale = int.Parse(drpGr adeScale.Select edValue);
valNumber = int.Parse(txtAQ QuizID.Text);
valEffectiveDat e = DateTime.Parse( txtEffectiveDat e.Text);
valActivityDate = DateTime.Now;

dsMain.QuizRow drv = dsMain1.Quiz.Ne wQuizRow();

drv.Quiz_Name = valName;
drv.Quiz_Status = valStatus;
drv.Quiz_Questi ons_PerPage = valQuestionsPer Page;
drv.Quiz_PassGr ade = valPassGrade;
drv.Quiz_User_I D = valUserID;
drv.Quiz_Author = valAuthor;
drv.Quiz_Activi ty_Date = valActivityDate ;
drv.SortType_ID = valSortType;
drv.NotifyOptio ns_ID = valNotifyOption s;
drv.GradeScale_ ID = valGradeScale;
drv.RetakeOptio n_ID = valRetakeOption ;
drv.Quiz_Effect ive_Date = valEffectiveDat e;
drv.Quiz_Number = valNumber;

dsMain1.Quiz.Ad dQuizRow(drv);

daQuiz.Update(d sMain1, "Quiz");

} //end if
Nov 16 '05 #1
4 2722
I think you do a DataBind() of the Controls with the DB before updating it

Let me guess:

In the OnLoad method you fill the DataSet and bind the Controls with it
In the OnClick event you try to update the DB

I'm right?

"gj" <jo****@boystow n.org> schrieb im Newsbeitrag
news:4f******** *************** ***@posting.goo gle.com...
Hi,

I'm trying to update a sql database from a web form using text boxes.
I'm trying to learn C# on my own so I am at a complete loss. I created
my sql connection, data adapter, dataset and data view in the visual
studio designer. I'm trying to keep a history of the record so instead
of editing the record I insert a new record with my changes. Instead
of the changes, it inserts the orginal record. Below is the part of
the code. Any help would be appreiated.

else if (txtTask.Text.T rim() == "1")
{
//assign values to variables
valName = txtName.Text.To String();
valStatus = txtStatus.Text. ToString();
valQuestionsPer Page = short.Parse(txt QuestionsPerPag e.Text);
valRetakeOption = int.Parse(drpRe takeOption.Sele ctedValue);
valPassGrade = short.Parse(txt PassGrade.Text) ;
valAuthor = txtAuthor.Text. ToString();
valUserID = "jongay";
valSortType = int.Parse(drpSo rtType.Selected Value);
valNotifyOption s = int.Parse(drpNo tifyOptions.Sel ectedValue);
valGradeScale = int.Parse(drpGr adeScale.Select edValue);
valNumber = int.Parse(txtAQ QuizID.Text);
valEffectiveDat e = DateTime.Parse( txtEffectiveDat e.Text);
valActivityDate = DateTime.Now;

dsMain.QuizRow drv = dsMain1.Quiz.Ne wQuizRow();

drv.Quiz_Name = valName;
drv.Quiz_Status = valStatus;
drv.Quiz_Questi ons_PerPage = valQuestionsPer Page;
drv.Quiz_PassGr ade = valPassGrade;
drv.Quiz_User_I D = valUserID;
drv.Quiz_Author = valAuthor;
drv.Quiz_Activi ty_Date = valActivityDate ;
drv.SortType_ID = valSortType;
drv.NotifyOptio ns_ID = valNotifyOption s;
drv.GradeScale_ ID = valGradeScale;
drv.RetakeOptio n_ID = valRetakeOption ;
drv.Quiz_Effect ive_Date = valEffectiveDat e;
drv.Quiz_Number = valNumber;

dsMain1.Quiz.Ad dQuizRow(drv);

daQuiz.Update(d sMain1, "Quiz");

} //end if

Nov 16 '05 #2
gj
You are right. I do fill the DataSet in the Page_Load method. Then I
do this.Databind() ;. When I fill out the web form and click Submit,
the value in the text box changes back to the orginal value before it
accesses my code in the OnClick event. I bound the textbox to the
DataView in Visual Studio designer using the textbox properties. Did I
do this wrong? Do I need to redo the DataBind() in the OnClick event?

Thanks

"Zürcher See" <aq****@cannabi smail.com> wrote in message news:<Ox******* *******@tk2msft ngp13.phx.gbl>. ..
I think you do a DataBind() of the Controls with the DB before updating it

Let me guess:

In the OnLoad method you fill the DataSet and bind the Controls with it
In the OnClick event you try to update the DB

I'm right?

"gj" <jo****@boystow n.org> schrieb im Newsbeitrag
news:4f******** *************** ***@posting.goo gle.com...
Hi,

I'm trying to update a sql database from a web form using text boxes.
I'm trying to learn C# on my own so I am at a complete loss. I created
my sql connection, data adapter, dataset and data view in the visual
studio designer. I'm trying to keep a history of the record so instead
of editing the record I insert a new record with my changes. Instead
of the changes, it inserts the orginal record. Below is the part of
the code. Any help would be appreiated.

else if (txtTask.Text.T rim() == "1")
{
//assign values to variables
valName = txtName.Text.To String();
valStatus = txtStatus.Text. ToString();
valQuestionsPer Page = short.Parse(txt QuestionsPerPag e.Text);
valRetakeOption = int.Parse(drpRe takeOption.Sele ctedValue);
valPassGrade = short.Parse(txt PassGrade.Text) ;
valAuthor = txtAuthor.Text. ToString();
valUserID = "jongay";
valSortType = int.Parse(drpSo rtType.Selected Value);
valNotifyOption s = int.Parse(drpNo tifyOptions.Sel ectedValue);
valGradeScale = int.Parse(drpGr adeScale.Select edValue);
valNumber = int.Parse(txtAQ QuizID.Text);
valEffectiveDat e = DateTime.Parse( txtEffectiveDat e.Text);
valActivityDate = DateTime.Now;

dsMain.QuizRow drv = dsMain1.Quiz.Ne wQuizRow();

drv.Quiz_Name = valName;
drv.Quiz_Status = valStatus;
drv.Quiz_Questi ons_PerPage = valQuestionsPer Page;
drv.Quiz_PassGr ade = valPassGrade;
drv.Quiz_User_I D = valUserID;
drv.Quiz_Author = valAuthor;
drv.Quiz_Activi ty_Date = valActivityDate ;
drv.SortType_ID = valSortType;
drv.NotifyOptio ns_ID = valNotifyOption s;
drv.GradeScale_ ID = valGradeScale;
drv.RetakeOptio n_ID = valRetakeOption ;
drv.Quiz_Effect ive_Date = valEffectiveDat e;
drv.Quiz_Number = valNumber;

dsMain1.Quiz.Ad dQuizRow(drv);

daQuiz.Update(d sMain1, "Quiz");

} //end if

Nov 16 '05 #3
This is my way:
In the onload method:
-fill the dataset
-if page is postback get the value from the controls and add/update them in
the dataset
-if page is not postback bind controls with the dataset

In the onclick method (for example 'save')
-Use dataadapter to update DB
-Bind controls with the dataset

On_Load()
{
...
FillDataSetWith DataAdapter();
if (!Page.IsPostba ck) BindControls();
else GetValueFromCon trolsAndUpdateD ataSet();
...
}

OnClick_Save()
{
DataAdapterUpda teDataSet();
BindControls();
}

OnClick_New()
{
AddANewRowToThe DataSet();
BindControls();
}

BindControls()
{
... //here bind the controls with the dataset
}
"gj" <jo****@boystow n.org> schrieb im Newsbeitrag
news:4f******** *************** ***@posting.goo gle.com...
You are right. I do fill the DataSet in the Page_Load method. Then I
do this.Databind() ;. When I fill out the web form and click Submit,
the value in the text box changes back to the orginal value before it
accesses my code in the OnClick event. I bound the textbox to the
DataView in Visual Studio designer using the textbox properties. Did I
do this wrong? Do I need to redo the DataBind() in the OnClick event?

Thanks

"Zürcher See" <aq****@cannabi smail.com> wrote in message

news:<Ox******* *******@tk2msft ngp13.phx.gbl>. ..
I think you do a DataBind() of the Controls with the DB before updating it
Let me guess:

In the OnLoad method you fill the DataSet and bind the Controls with it
In the OnClick event you try to update the DB

I'm right?

"gj" <jo****@boystow n.org> schrieb im Newsbeitrag
news:4f******** *************** ***@posting.goo gle.com...
Hi,

I'm trying to update a sql database from a web form using text boxes.
I'm trying to learn C# on my own so I am at a complete loss. I created
my sql connection, data adapter, dataset and data view in the visual
studio designer. I'm trying to keep a history of the record so instead
of editing the record I insert a new record with my changes. Instead
of the changes, it inserts the orginal record. Below is the part of
the code. Any help would be appreiated.

else if (txtTask.Text.T rim() == "1")
{
//assign values to variables
valName = txtName.Text.To String();
valStatus = txtStatus.Text. ToString();
valQuestionsPer Page = short.Parse(txt QuestionsPerPag e.Text);
valRetakeOption = int.Parse(drpRe takeOption.Sele ctedValue);
valPassGrade = short.Parse(txt PassGrade.Text) ;
valAuthor = txtAuthor.Text. ToString();
valUserID = "jongay";
valSortType = int.Parse(drpSo rtType.Selected Value);
valNotifyOption s = int.Parse(drpNo tifyOptions.Sel ectedValue);
valGradeScale = int.Parse(drpGr adeScale.Select edValue);
valNumber = int.Parse(txtAQ QuizID.Text);
valEffectiveDat e = DateTime.Parse( txtEffectiveDat e.Text);
valActivityDate = DateTime.Now;

dsMain.QuizRow drv = dsMain1.Quiz.Ne wQuizRow();

drv.Quiz_Name = valName;
drv.Quiz_Status = valStatus;
drv.Quiz_Questi ons_PerPage = valQuestionsPer Page;
drv.Quiz_PassGr ade = valPassGrade;
drv.Quiz_User_I D = valUserID;
drv.Quiz_Author = valAuthor;
drv.Quiz_Activi ty_Date = valActivityDate ;
drv.SortType_ID = valSortType;
drv.NotifyOptio ns_ID = valNotifyOption s;
drv.GradeScale_ ID = valGradeScale;
drv.RetakeOptio n_ID = valRetakeOption ;
drv.Quiz_Effect ive_Date = valEffectiveDat e;
drv.Quiz_Number = valNumber;

dsMain1.Quiz.Ad dQuizRow(drv);

daQuiz.Update(d sMain1, "Quiz");

} //end if

Nov 16 '05 #4
gj
Thanks, I really appreciate your help.

Gayle

"Zürcher See" <aq****@cannabi smail.com> wrote in message news:<ux******* *******@TK2MSFT NGP15.phx.gbl>. ..
This is my way:
In the onload method:
-fill the dataset
-if page is postback get the value from the controls and add/update them in
the dataset
-if page is not postback bind controls with the dataset

In the onclick method (for example 'save')
-Use dataadapter to update DB
-Bind controls with the dataset

On_Load()
{
...
FillDataSetWith DataAdapter();
if (!Page.IsPostba ck) BindControls();
else GetValueFromCon trolsAndUpdateD ataSet();
...
}

OnClick_Save()
{
DataAdapterUpda teDataSet();
BindControls();
}

OnClick_New()
{
AddANewRowToThe DataSet();
BindControls();
}

BindControls()
{
... //here bind the controls with the dataset
}
"gj" <jo****@boystow n.org> schrieb im Newsbeitrag
news:4f******** *************** ***@posting.goo gle.com...
You are right. I do fill the DataSet in the Page_Load method. Then I
do this.Databind() ;. When I fill out the web form and click Submit,
the value in the text box changes back to the orginal value before it
accesses my code in the OnClick event. I bound the textbox to the
DataView in Visual Studio designer using the textbox properties. Did I
do this wrong? Do I need to redo the DataBind() in the OnClick event?

Thanks

"Zürcher See" <aq****@cannabi smail.com> wrote in message

news:<Ox******* *******@tk2msft ngp13.phx.gbl>. ..
I think you do a DataBind() of the Controls with the DB before updating it
Let me guess:

In the OnLoad method you fill the DataSet and bind the Controls with it
In the OnClick event you try to update the DB

I'm right?

"gj" <jo****@boystow n.org> schrieb im Newsbeitrag
news:4f******** *************** ***@posting.goo gle.com...
> Hi,
>
> I'm trying to update a sql database from a web form using text boxes.
> I'm trying to learn C# on my own so I am at a complete loss. I created
> my sql connection, data adapter, dataset and data view in the visual
> studio designer. I'm trying to keep a history of the record so instead
> of editing the record I insert a new record with my changes. Instead
> of the changes, it inserts the orginal record. Below is the part of
> the code. Any help would be appreiated.
>
> else if (txtTask.Text.T rim() == "1")
> {
> //assign values to variables
> valName = txtName.Text.To String();
> valStatus = txtStatus.Text. ToString();
> valQuestionsPer Page = short.Parse(txt QuestionsPerPag e.Text);
> valRetakeOption = int.Parse(drpRe takeOption.Sele ctedValue);
> valPassGrade = short.Parse(txt PassGrade.Text) ;
> valAuthor = txtAuthor.Text. ToString();
> valUserID = "jongay";
> valSortType = int.Parse(drpSo rtType.Selected Value);
> valNotifyOption s = int.Parse(drpNo tifyOptions.Sel ectedValue);
> valGradeScale = int.Parse(drpGr adeScale.Select edValue);
> valNumber = int.Parse(txtAQ QuizID.Text);
> valEffectiveDat e = DateTime.Parse( txtEffectiveDat e.Text);
> valActivityDate = DateTime.Now;
>
> dsMain.QuizRow drv = dsMain1.Quiz.Ne wQuizRow();
>
> drv.Quiz_Name = valName;
> drv.Quiz_Status = valStatus;
> drv.Quiz_Questi ons_PerPage = valQuestionsPer Page;
> drv.Quiz_PassGr ade = valPassGrade;
> drv.Quiz_User_I D = valUserID;
> drv.Quiz_Author = valAuthor;
> drv.Quiz_Activi ty_Date = valActivityDate ;
> drv.SortType_ID = valSortType;
> drv.NotifyOptio ns_ID = valNotifyOption s;
> drv.GradeScale_ ID = valGradeScale;
> drv.RetakeOptio n_ID = valRetakeOption ;
> drv.Quiz_Effect ive_Date = valEffectiveDat e;
> drv.Quiz_Number = valNumber;
>
> dsMain1.Quiz.Ad dQuizRow(drv);
>
> daQuiz.Update(d sMain1, "Quiz");
>
> } //end if

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2431
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from code it is 50% chance that the update will make it back to the dataset. If I update the dataset instead of the form, it does not show on the form. Is there a method that should be used?
2
2871
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter Wizard with generatedDataset and generated Select, Update, Insert and Deletecommands, controls bound to DataSet using the AdvancedDatabinding properties) Issue: Do I have to set parameters before I issue theDataSet.Update(Dataset, )? Again, my...
0
5812
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database which indexes computer magazine articles for personal reference. I am developing a Visual Basic.NET program whose sole purpose is to enter new records into the database. No updates to existing entries, no deletions, and no display
5
357
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from code it is 50% chance that the update will make it back to the dataset. If I update the dataset instead of the form, it does not show on the form. Is there a method that should be used?
0
8487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8932
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8831
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8611
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8683
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1819
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.