DataSource Controls :: Update Field In Db?

Mar 14, 2011

I am facing problem in my update statement,

Dim abc As String
abc = Request.QueryString("str")
Dim userName As String = CStr(Session("user"))
Label2.Text = userName
Dim MyConnection As New OdbcConnection(ConnStr)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
If MyCommand.CommandText = "Select userid from week where userid ='" & userName & "'" Then
MyCommand.CommandText = "Update week Set value = '" & abc & "' where userid ='" & userName & "'"
Else
MyCommand.CommandText = "INSERT INTO week (value, userid) VALUES('" & abc & "','" & userName & "')"
End If
MyCommand.ExecuteNonQuery()
MyConnection.Close()

View 18 Replies


Similar Messages:

DataSource Controls :: Update Tabel Field?

Dec 25, 2010

i need to update one field in a tabel just to +2 and i can not find out how to do it the code i have write until now is just to find the field i has to update this i the code

[Code]....

write the last code there can +2 to a.point field in my db

View 2 Replies

DataSource Controls :: Update A Field That Isn't In The Row Using A Button In Gridview?

Oct 28, 2010

I have a gridview which shows a list of data... at the end of each item I have added a button which is linked to the onclick event... when a button is clicked I want a value to update on that specific row... but I can't get it to work :( my code is below...

SqlDataSource 1 code...

UpdateCommand="UPDATE [PurchaseProduct] SET [BDConfirmSent] = 'Yes' Where [Id] = @Id">
<UpdateParameters>
<asp:Parameter Name="Id" />
<asp:Parameter Name="BDConfirmSent" />
</UpdateParameters>

Code Behind...

Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating
e.Command.Parameters("@BDConfirmSent").Value = "Yes"
End Sub
Protected Sub Button1_Click()
SqlDataSource1.Update()
End Sub

When I click the button it just postsback the page but then the [BDConfirmSent] field is still empty instead of being "Yes"

View 4 Replies

DataSource Controls :: Relational Field Not Updating On Update?

Mar 1, 2010

I have detailsview with a SQLDataSource to 1 table (City) and am referencing another table (Unit) for one if it's fields.

[code]....

I changed the Unit Code (City Table) field into a template field and am using a dropdownlist item to reference the Unit Name from the (Unit Table) with the CityTable.Unit Code = UnitTable.Unit Code. However when I go into the update and change the dropdownlist item to another Unit Name it is keeping the original Unit Code value or it might even be selecting the first value from the dropdownlist item.

View 1 Replies

DataSource Controls :: Update One Field Only From Multiple Options?

Dec 6, 2010

i am attempting to update one field; either the data field or filename from a record but not both at same time.

i am using a stored procedure like.

@id int,

[Code]....

View 7 Replies

DataSource Controls :: Update Table Field With LINQ To SQL And Query String

Jul 11, 2010

I am trying to update my table ARTICLES and it has a field COUNTER, Everytime a user enter this ARTICLES, the page_load event runs a LINQ to SQL query taking the QueryString as parameter, increasing the COUNTER field in 1.

[Code]....

View 2 Replies

DataSource Controls :: : Update A Date Field To The System Date But It's Not Working?

Jan 27, 2010

I'm trying to update a date field to the system date but it's not working. Could someone please help with the syntax?

[Code]....

View 18 Replies

DataSource Controls :: Ignore Empty Field Because Always Join The Field And Separate By Space

Mar 3, 2010

I wanna join all the field as a new col.

but how can i ignore the empty field because i always join the field and separate by space like the following.

select (field_1+' '+field_2+' '+field_3) as new_col from TABLEA

but if the field is empty, then there is the double space

how can i ensure all the space is one space only.

View 2 Replies

DataSource Controls :: Set Field As DBNull.Value If Field Is Blank?

Apr 7, 2010

I have a 20 to 30 fields on a form. Most of them are optional. However, the users can fill out what they want. If a user dosen't fill in a field when data is sent to the database it's sent as blank, instead of NULL. Is there a way I can generically say "for all textboxes if Equals("") then DBNull.Value". Without going through each and every textbox?

View 2 Replies

DataSource Controls :: Used Sqldatasource For Performing And Update Query But How To Update The Record On Click

Nov 9, 2010

Here is the sqldatasource config code: <asp:SqlDataSource ID="SqlDataSource1" runat="server"

View 1 Replies

DataSource Controls :: Update The Data Of A Database Through A Gridview Update Button?

Apr 19, 2010

i want to update the data of a database through a gridview update button

how can i attach a dataconvertion like this

[Code]....

View 1 Replies

DataSource Controls :: Cannot Update DataBase By Using UPDATE Query

Jul 6, 2010

[code]....

Im trying to update my DB(DataBase) by using SQL UPDATE query ,but its not updating in the dataBase i receive confirmation(in testLabel) that one row is affected(dataReader = query.ExecuteReader(); return numbers of rows affected)...

I have given a HTML editortext control on a page,which generates HTML (i have to store it in my DB,that page is only for Admin) ,on pressing Update button , im receving in my testLabel that one row is affected(which shows DB is updated succesfully) but when i check my DB its in old state,it is not updating...

Here is my Event handler of Update Button which have to make updates in DB:

[Code]....

[Code]....

View 2 Replies

DataSource Controls :: DataContext Update Doesn't Update?

Jun 21, 2010

What's wrong with the following code?

[Code]....

After the SubmitChanges call, the Text field in data2 wasn't changed. According to the NerdDinner sample, I supposedly can just write to my data object and then call SubmitChanges.

View 5 Replies

Forms Data Controls :: Update Field Based On Value In Another?

Apr 9, 2010

In GridView (using VB) , I have project information, with Status and %Complete that the user is supposed to update. Trouble is they may change %Complete to 100%, but not change the status from Active to Complete. So, we wind up with a long list of Active tasks that are 100% Complete. How can I force an update to the Status field ? something like... If "%Complete" = "100" Else Status = "Complete" Not sure if I need to do this in VBscript or code behind or SQL or.

View 2 Replies

DataSource Controls :: Update 1 Row = 1 And Update All Other Rows = 0?

Apr 12, 2010

I have an update / insert statements. If the user selects the checkbox IsPrestigeFeatured, I want that row to be set to 1 and I want all other rows to be set to 0. E.g. so there is only one row which is "Is prestige Featured"

My update statement:

ALTER PROCEDURE dbo.Update_Property
@propertyId int,
@propertyTypeId int,
@Name ntext,
@Price int,
@DescriptionResultsExcerpt text,
@Description ntext,
@Characteristics ntext,
@IsRenovation int,
@IsCharacter int,
@IsPrestige int,
@IsHomepageFeatured int,
@IsPrestigeFeatured int,
@CityId int,
@DepartmentId int,
@CommuneId int

As
UPDATE Property
SET Name = @Name, PropertyTypeID = @propertyTypeId, Price = @Price,
DescriptionResultsExcerpt = @DescriptionResultsExcerpt,
Description = @Description, Characteristics = @Characteristics,
IsRenovation = @IsRenovation, IsCharacter = @IsCharacter,
IsPrestige = @IsPrestige, IsHomepageFeatured = @IsHomepageFeatured,
IsPrestigeFeatured = @IsPrestigeFeatured, CityId = @CityId,
DepartmentId = @DepartmentId, CommuneId = @CommuneId
FROM Property
WHERE (PropertyID = @PropertyID)

View 12 Replies

Forms Data Controls :: Gridview Update From Template Field Not Updating

Feb 3, 2011

I have a gridview where I am using the update. I have converted the label into a templatefield and added a dropdownlist which is getting polulated in the Rowdatabound event. When I test the update i get an error

Cannot insert the value NULL into column 'StartTime', table 'HTC.dbo.EventDates'; column does not allow nulls. UPDATE fails.The statement has been terminated. so I am ussuming its still trying to update from the label rather than using the dropdownlist. here is my code:

[Code]....

View 1 Replies

Forms Data Controls :: How To Update A Dynamic Control Field In A Formview

Jun 28, 2010

I have created a formview with 4 dynamic controls fields that LINQ to a database.

rentfoodutilitytotal

There's an event handle for each of the first three fields whenever a text change with following codes:

' extract textbox from both SubTotal and the modified field
tboxSubtotal = FormViewAssistance2.FindControl("totalTextBoxEdit")
tboxModifier = FormViewAssistance2.FindControl("foodTextBoxEdit")
'extract string from those textboxes
txtSubtotal = tboxSubtotal.Text
txtModifier = tboxModifier.Text
'convert text to double and add them together
Double.TryParse(txtModifier, dblModifier)
Double.TryParse(txtSubtotal, dblSubtotal)
dblSubtotal = dblSubtotal + dblModifier
'post the changes back to SubTotalTextBoxEdit
'totalTextBoxEdit
'EditorPart.ReferenceEquals("totalTextBoxEdit", dblSubtotal)
'PostBackTrigger.ReferenceEquals("SUBTOTRECTextBoxEdit", dblSubtotal)
'EditorZone.ReferenceEquals("SUBTOTRECTextBoxEdit", dblSubtotal)

I'm stuck on how to post/update totalTextBoxEdit to reflex changes in first three fields without having user clicking Update button to save the information into database. I've tried above 3 statements but none of them is working.

View 9 Replies

Forms Data Controls :: Update Mark And Convert To Template Field

Oct 8, 2010

Im using agrid view which does not using sql datasource and im trying ro Update it this is the Code:

public partial class senior_MarksApproval : PageDataAccess
{
protected void Page_Load(object sender, EventArgs e)
{
Title = "View Marks Approval Requests";
if (IsPostBack)
{
DataTable Ds = DA.getSemester();
lblsem.Text = Ds.Rows[0]["SemID"].ToString();
BindGrid();
}
}
void BindGrid()
{
DataTable DT = DA.GetMarksReqApproval(Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToString(DropDownList2.SelectedValue));
GridView1.DataSource = DT;
GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
String CID = GridView1.DataKeys[e.RowIndex][0].ToString();
String STDNo = GridView1.DataKeys[e.RowIndex][1].ToString();
String Mark = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
DA.EditMarks(CID, STDNo, Convert.ToInt32(Mark), DateTime.Now.ToString());
GridView1.EditIndex = -1;
BindGrid();
}

I want To update Mark and i convert it to template Field ,When I press Update I get the Old value not the Newest One of The Mark and nothing were Updated Except The Date Value in each DataBase and Grid

View 8 Replies

Forms Data Controls :: Extract Value From Template Field To Use In Update Query

Jan 3, 2011

I put a dropdownlist in a template field with 4 choices with the values of each to a,b,c,d and when i run the update query i need it to pull from that selected row,and read the value selected in that field. I tried this:

@choice = SelectedRow.Cells[9].Text.ToString() but it didnt work

how can i extract data from a dropdownlist thats inside a template field and use in a update query?

View 8 Replies

Forms Data Controls :: Update Database Field With Textbox OnChange?

Jan 20, 2010

I've been searching for a tutorial or example on how to update my database when I change the text in the textbox that is in a DataList?

View 8 Replies

Data Controls :: Update Database Field And Label In GridView Using DropDownList

Feb 26, 2013

Am having one gridview. In that there is some details and one hyperlink (for Mail) and one Label (Mail Status).

The Mail status label have default value Not Sent for all fields. If i click the Mail link and send mail to the corresponding person, then the Default label value will be automatically changed its text to Sent.

View 1 Replies

Forms Data Controls :: GridView Not Updating / After Clicking Update Command Field?

Mar 12, 2011

I have a gridview and sqldatasource in a form. My sqldatasource has select,delete and update command. The delete command is working but the update doest not work when I click the update command field.

Here is my code [Code]....

View 3 Replies

Forms Data Controls :: Update A Field In A Gridview To False On A Button Click

Sep 3, 2010

Ive got a list of records in a gridview (from an SQLDataSource) where a field value is set to True. I've also added a "reset" button in a template field at the start of the row in the Gridview.

What I would like to do is allow the user to click the reset button on a particular row and 'reset' the true value to 'false' (updating the source data).

View 6 Replies

Data Controls :: Update Database Field Using DropDownList In Edit ItemTemplate Of GridView

Mar 10, 2013

[URL]

but i wanted know,how to update the country of any customer by just choosing it from the dropdownlist and updating it in the databse.

i  wanted to add a common update below that updated the country of customers.

View 1 Replies

DataSource Controls :: How To Split Field In Sql

Jan 24, 2010

I have field_1, the data format store in the field is about "Mary, Amy, Billy, Ma"

how can i extract the record that the field_1 has Mary.

I can't use the like'%Mary%' because it can extract 'Ma' too.

I would like to extract exactly Mary. or can i split the field_1 by ',' in sql?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved