Help With Updating Changes

Nov 29, 2007

I have some code to hack in c#..
I have a database and when a form (C#) is loaded a copy of the table is made in a DataTable object. The form has a list box showing just the one column of info from the local DataTable.
On the form it is possible to change a record, delete a record and add a record. These are all done in the local table.

The question, how do i send these changes back to the database. Currently it deletes the lot and copies all the local table values in. How do only do the affected row, UPDATE, INSERT etc

View 1 Replies


ADVERTISEMENT

Updating A Table By Both Inserting And Updating In The Data Flow

Sep 21, 2006

I am very new to SQL Server 2005. I have created a package to load data from a flat delimited file to a database table. The initial load has worked. However, in the future, I will have flat files used to update the table. Some of the records will need to be inserted and some will need to update existing rows. I am trying to do this from SSIS. However, I am very lost as to how to do this.

Any suggestions?

View 7 Replies View Related

Updating

Aug 24, 2007

I am trying to make a stored procedure in my website for updating an address:1 CREATE PROCEDURE dbo.UPDATE
2 (
3 @add NVarchar(50),
4 @cit NVarchar(50),
5 @state NVarchar(50),
6 @zip NVarchar(50),
7 @CNum int
8 )
9
10 UPDATE table_name
11 AppAdd = @add, AppCity = @cit, AppState = @state, AppZip = @zip
12 WHERE CertNum = @CNum When I try to save it it give me an error: Incorrect syntax near keyword 'UPDATE'Must declare scalar variable '@add'
 

View 1 Replies View Related

I Am New To Asp.net And I Need Help With Updating

Feb 24, 2008

Hi, I'm new to ASP.Net quite new to C# (My first attempt at a database website) and am trying to get a button to add "1" to "int" value called "Comments" a each time its pressed basically counting each time a comment is added. I also only wnat it to affect the row where "ModID" in my database is equal to the query string "ModID" I'm using on the page. I cannot find any tutorials so this is my best guess so far. This is probably a Noobie type stupid question but I'm stuck.  This is the code I have so far for my Button_Click event:  protected void Button_Click(object sender, EventArgs e){        SqlDataSource CommentCountDataSource = new SqlDataSource();        CommentCountDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["Main_Site_DatabaseConnectionString1"].ToString();        CommentCountDataSource.UpdateCommandType = SqlDataSourceCommandType.Text;        CommentCountDataSource.SelectCommand = "SELECT (ModID, DateTimeLastComment, Comments) FROM Mods";        CommentCountDataSource.UpdateCommand = "UPDATE Mods SET (DateTimeLastComment=@DateTimeLastComment, Comments=@Comments) WHERE ModID=@ModID"; //How do i get the Where to use the query string info?                CommentCountDataSource.UpdateParameters.Add("DateTimeLastComment", DateTime.Now.ToString());                CommentCountDataSource.UpdateParameters.Add("Comments", "10");     //"10" is just a value to test I'll change this to add "1" once I figure how.        CommentCountDataSource.Update();}  Sorry if I'm using the wrong lingo but as I say I'm new. If my code is a mile off then please can you send me in the right direction of some code that works.Thanks in advance if anyone can help me. Cheers,Alan

View 5 Replies View Related

Updating

Apr 13, 2008

guys can anyone know whats wrong with my syntax? I always get this error: ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.This is the syntax: Protected Sub btnupd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupd.Click        Dim pwing, pblood, pcolor, plcolor, pmark, pbdate, pstat, premark, ppefr, pstyle As Object        Dim sql As String        Dim y As New Object        y = GVh.SelectedDataKey(0)        pwing = txtwingb.Text        pblood = txtblood.Text        pcolor = txtcolor.Text        plcolor = txtlcolor.Text        pmark = txtmark.Text        pbdate = ddday.SelectedValue & "-" & Ddmonth.SelectedValue & "-" & ddyear.SelectedValue        pstat = txtstat.Text        premark = txtremark.Text        sql = "UPDATE [broodhen]"        sql = sql & " SET bwing = '" & pwing & "',"        sql = sql & " bloodlines = '" & pblood & "',"        sql = sql & " color = '" & pcolor & "',"        sql = sql & " lcolor = '" & plcolor & "',"        sql = sql & " mark = '" & pmark & "',"        sql = sql & " bday = '" & pbdate & "',"        sql = sql & " status = '" & pstat & "',"        sql = sql & " remarks = '" & premark & "'"        sql = sql & " WHERE(bwing = '@wwing')"        DShen.UpdateCommand = sql        DShen.Update()        MView.SetActiveView(GView)    End SubThat is from my aspx.vb file and for the .aspx my datasource:<asp:SqlDataSource ID="DShen" runat="server"             ConnectionString="<%$ ConnectionStrings:CSD %>"             ProviderName="<%$ ConnectionStrings:CSD.ProviderName %>"             SelectCommand="SELECT * FROM [broodhen]" > </asp:SqlDataSource>  Note: I select records from a gridview to edit. i can delete, insert, select but i cant update. please help... tnx.

View 3 Replies View Related

Updating A DB

Jul 28, 2005

I am trying to update a SQL Server DB via my ASP.NET application with the following SqlCommand:

UPDATE    StudentCourses
SET              SC_Active = 0
WHERE     (UT_ID IN (@UT_IDs)) AND (CO_ID = @CO_ID)

@UT_IDs in populated from a StringBuilder object with the following:
354,284,305,281,308,351,439,355,306,282

When I run the application to update the DB, I get the error:
System.FormatException: Input string was not in a correct format.

If I change @UT_IDs to:
354
if works.

Can anyone explain this behaviour?

Cheers,
ocann

View 1 Replies View Related

Updating

Feb 8, 2001

I am a DBA who is moving in the direction of minor database design. I have gone through the steps to get my tables normalized, and I am ready to get them set up so they will update from table to table. How do I set this up? I know SQL does not cascade like Access, so how is this done? From what I have read (Robert Vieira's book) I should use triggers? Any help would be appreciated. Dallas

View 1 Replies View Related

Updating

Aug 30, 2005

I have a query that updates

strSQL = "UPDATE customers SET "
strSQL &= "entryid = '" & strtheEntryid & " ' "
strSQL &= "WHERE id =1 "
right now in table id is my primary key field it increments by 1, I want to say get first record instead of saying id = 1, how to do that?

View 2 Replies View Related

Updating With ADO.net

Mar 25, 2008

Hey

I have an ASP application that uses a stored procedure and ADO.net to update a sql server data file. The problem is I know the code is working, I don't have any errors with the ADO, no exceptions are caught. I can use the same basic code to insert a record using a different procedure. It is the update procedure that does not carry through.

So, I know I have a connection, the procedure works using the query builder directly so the procedure works, but when I run the code, I get no errors and no update to the datafile. I am not even sure how to trouble shoot this since I don't have an error to look up.

C# Code:-------------

private void UpdateIssue()
{
DateTime date = new DateTime();
date = Convert.ToDateTime(this.txtDate.Text);

//edit record in HelpDeskIssuesTbl here.

SqlConnection con = new SqlConnection("Data Source...");
SqlCommand comUpdateTicket = new SqlCommand("sp_UpdateHelpDeskIssues", con);
comUpdateTicket.CommandType = CommandType.StoredProcedure;
comUpdateTicket.Parameters.Add("@IssueID", this.GridView1.SelectedIndex.ToString());
comUpdateTicket.Parameters.Add("@EmpID", this.ddlEmployee.SelectedValue.ToString());
comUpdateTicket.Parameters.Add("@Date", date.ToShortDateString());
comUpdateTicket.Parameters.Add("@StatusID", this.ddlStatus.SelectedValue.ToString());

try
{
con.Open();
comUpdateTicket.ExecuteNonQuery();

}
catch (Exception ex)
{
this.lblMessage.Text = "Data save error: " + ex.Message.ToString();
this.pnlMessage.Visible = true;
}
finally
{
con.Close();
}
}

----------------------------------------------------
dbo.sp_UpdateHelpDeskIssues

(
@IssueID int,
@EmpID int,
@Date datetime,
@StatusID int
)

AS
UPDATE HelpDeskIssuesTbl
SET EmployeeID = @EmpID, IssueDate = @Date, IssueStatusID = @StatusID
WHERE (IssueID = @IssueID)
RETURN

Like I said the Stored Procedure does work when I run it directly in Visual Studio. I have double checked all the params and they all match up unless I am missing something.

Please send help! Thanks.

View 2 Replies View Related

SCD Not Updating

Jul 17, 2007

Hi gurus,


My feeling with the SCD component is not that very solid. I have the feeling that the behavior of the insert/update strategy is not always correct an working.
I will describe two problems that i encounter.

1. My destination table contains records with the value ''. Cause i don't want '' ( 2 single quotes) in our DWH i update the view that is the source with a case statement that changes the '' to NULL. But when i run the packages the '' values are not update with the NULL values. When i delete the destination table and run the package, the records are inserted with the NULL value as expected. Anyone who has experienced this problem?

2. When i create a new table and run the package so the destination table gets filled with records the SCD will insert alle records (for example 100). When i start the run directly after the first run, all records are updated instead of doing nothing what it should do cause all records exists.

Anyone who can give me some feedback?

with regards, Arthur

View 15 Replies View Related

Updating A Row

Jun 27, 2006

Hi

I come from a Unix backgound and used Informix ISQL quite frequently.

I have a row that contains a compund field 'cust_and_date' and contains a value of C0003 32656

I want to write an update statement that will amend the C0003 to C00009 but leaves the 32656 as is.

I tried the following:-

update scheme.slitemm set substring(cust_and_date,1,8) = 'C00009'

This returned a syntax error

Any help gratefully received



View 5 Replies View Related

Updating A SqlDataSource

Dec 12, 2006

I am looking for a way to update a sqldatasource what I have is a ASP Wizard applicationstep oneis a dataview with the select ability it displays an ID and Namein step two what i want it to do is take the ID from step ones select and put that into the where clause so I have select * from table where id = step1selectedID

Code:

View 1 Replies View Related

Updating A Column In SQL

Dec 13, 2006

I am trying to update a users status from Pending to either Approved or Rejected.  I created the following handers to update me db by I keep getting a syntax error. What am I doing wrong? public partial class admin_beta : System.Web.UI.Page{    protected void ApproveButton_Click(object sender, EventArgs e)    {        SqlConnection conn = new SqlConnection("Data Source=TECATE;Initial Catalog=subscribe_mainSQL; User Id=maindb Password=$$ricardo; Integrated Security=SSPI");        SqlCommand cmd = new SqlCommand("UPDATE [main] ([status]) VALUES (@status)", conn);        conn.Open();        cmd.Parameters.AddWithValue("@status", "Approved");        int i = cmd.ExecuteNonQuery();        conn.Dispose();    }    protected void DenyButton_Click(object sender, EventArgs e)    {        SqlConnection conn = new SqlConnection("Data Source=TECATE;Initial Catalog=subscribe_mainSQL; User Id=maindb Password=$$ricardo; Integrated Security=SSPI");        SqlCommand cmd = new SqlCommand("UPDATE [main] ([status]) VALUES (@status)", conn);        conn.Open();        cmd.Parameters.AddWithValue("@status", "Rejected");        int i = cmd.ExecuteNonQuery();        conn.Dispose();    }}

View 4 Replies View Related

Sql Datasource Not Updating

Mar 6, 2007

I have this web store that I have been creating.  When a customer goes to check out, he has to log in, then he is redirected to a page where he can view/add/or edit shipping and billing address.  I have based all the sql statements on the profile username, adding records and retrieving them works just fine.  When I go to change something in the info it uses an sql statement that updates based on "Where AccountUserName = @AccountUserName", I have @AccountUserName set to Profile("Username").  Keep in mind this works fine for adding new or bring up current records.  I even put in code in the updated event for the sql data source to post a msgbox telling me how many rows were affected, it says 1 even though I dont see any change in the data.   What am I doing wrong here, it's driving me nuts, its just a very simple update. 

View 2 Replies View Related

Updating The Database

Mar 7, 2007

Hi All:

Appreciate your efforts in answering queries of so many newbees!I hope to find answering my query..I
have created a logon screen to which i have also given the option of
changing the password ... Now below is the code for updating the new
password given by the user ....Imports System.Data.SqlClient     Dim con As New SqlConnection("server=sys2;initial catalog=kris;integrated security=SSPI")    Dim cmd As New SqlCommand("select * from u_login", con)      Dim dr As SqlDataReader    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    End Sub    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click        con.Open()        dr = cmd.ExecuteReader        While dr.Read()            If dr(0) = txtEmail.Text And dr(1) = txtoldpwd.Text Then                Dim NewPwdStr As String = txtnewpwd.Text                Dim OldPwdStr As String = txtoldpwd.Text                Dim sqlstr As String = "Update U_Login set pwd = ('" & NewPwdStr & "') Where pwd = '" & OldPwdStr & "'"                Dim cmd1 As New SqlCommand("sqlstr", con)                                        cmd1.ExecuteNonQuery()                Response.Write(" Password Changed ... Please login again")            End If        End While        dr.Close()        con.Close()    End Sub The above code although doesnt
throw any error however it shows a blank screen and doesnt even update
the new password. Can you plz help me understand what could possibly be
wrong in my code n why is that am getting the blank screen. Your help will be highly appreciated!Thanks,Brandy

View 6 Replies View Related

SQL Server Is Not Updating

Jun 13, 2007

I am in a fix where I cant seem to update my records.  I am trying to follow a template for an Event calendar and cant seem to get the update page working correctly.   basically the update on the server never occurs but the message is still returned.  Very confused is it my stored procedure?
Imports System.Data
Imports System.Data.SqlClientPartial Class _Default
Inherits System.Web.UI.PageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Bind()
End SubSub Bind()Using Conn As New SqlConnection("Data Source=WINSERV;Initial Catalog=EventCalendar;User ID=antonio;Password=xxxx;User Instance=False")
Conn.Open()Dim cmd As New SqlCommand("sp_GetEvent", Conn)
cmd.CommandType = Data.CommandType.StoredProcedure
Dim ParameterID As New SqlParameter("@Event_ID", SqlDbType.Int, 4)ParameterID.Value = Request.QueryString("Event_ID")
cmd.Parameters.Add(ParameterID)Dim myDataReader As SqlDataReader
myDataReader = cmd.ExecuteReader
myDataReader.Read()txtapeDate.Text = myDataReader.Item("apeDate")
txtapEvent.Text = myDataReader.Item("apEvent")txtWho.Text = myDataReader.Item("Who")
txt_type.Text = myDataReader.Item("_type")txtEvent_ID.Text = myDataReader.Item("Event_ID")
myDataReader.Close()
Conn.Close()
End UsingEnd Sub
 Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
 Dim APEvent As String = txtapEvent.Text
Dim Who As String = txtWho.TextDim apeDate As String = txtapeDate.Text
Dim Event_ID As Integer = txtEvent_ID.TextDim _type As Integer = txt_type.Text
'add it to the DBUsing Conn As New SqlConnection("Data Source=WINSERV;Initial Catalog=EventCalendar;User ID=antonio;Password=xxxx;User Instance=False")
Conn.Open()Dim cmd As New SqlCommand("sp_editSingleEvent", Conn)
cmd.CommandType = Data.CommandType.StoredProcedurecmd.Parameters.AddWithValue("@Who", Who)
cmd.Parameters.AddWithValue("@apEvent", APEvent)cmd.Parameters.AddWithValue("@apeDate", apeDate)
cmd.Parameters.AddWithValue("@_type", _type)cmd.Parameters.AddWithValue("@Event_ID", Event_ID)
cmd.Parameters.Add(New SqlParameter("@message", SqlDbType.VarChar, 200))cmd.Parameters("@message").Direction = ParameterDirection.Output
cmd.ExecuteNonQuery()Dim sMessage As String = Convert.ToString(cmd.Parameters("@message").Value)
Conn.Close()
lblMessage.Text = sMessage
End Using
End Sub
 
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("MainEvent.aspx")End Sub
End Class
 ===========Stored Procedure==========USE [EventCalendar]
GO
/****** Object: StoredProcedure [dbo].[sp_EditSingleEvent] Script Date: 06/13/2007 15:15:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GOALTER PROCEDURE [dbo].[sp_EditSingleEvent]
-- Add the parameters for the stored procedure here
@apeDate smalldatetime,
@apEvent nvarchar(250),
@who nvarchar (50),
@Event_ID int,
@message nvarchar (200)OUTPUT,@_type int
AS
Begin
Set @Message = 'Hasnt added yet'
UPDATE apEvent
SET apeDate=@apeDate, apEvent=@apEvent, Who=@Who, _type=@_type
WHERE Event_ID = @Event_ID
Set @message = 'its added'
END

View 2 Replies View Related

Updating Problem

Jun 26, 2007

CREATE PROCEDURE discussions_DeletePost@post_id as intAS--prepare the variable to hold the topic_id of the post we are deletingDECLARE @topic_id int--get the topic_id from the post we are going to deleteSET @topic_id  = (SELECT topic_id from discussions_PostsWHERE post_id = @post_id)--now that we now what topic the post was in, we can delete the postDELETE FROM discussions_PostsWHERE post_id = @post_id--update topics, and just in case, if the post we deleted was the last post from the topic, give the topic a new last post_idUPDATE discussions_Topics SET topic_last_post_id = (SELECT MAX(post_id) FROM discussons_Posts WHERE topic_id = @topic_id)        WHERE topic_id = @topic_id    RETURN The problem with this is that, if I delete the last post from the topic, the topic_last_post_id feild does not update with a new post_id Any help? 

View 3 Replies View Related

Updating Problems

Aug 24, 2007

Hi
 I'm new to all of this. I have a database that holds customer
information (fictitious) and i can select that data and display it in a
set of textboxes. I also have an SQL command "UPDATE" that is designed
to update the text field that i want to edit. However the problem i'm
having is that it'll let me write the info in the textbox but as soon
as i click my update button it just flashses and goes back to what it
says before
 e.g. FIRST NAME: LEE      i enter TOM and then it reverts it back to LEE
This is my SQL UPDATE command statement:


UPDATE CustomerDetails SET [First Name] = @firstnameTextBox, [Last
Name] = @lastnameTextBox, [Address line 1] = @addressTextBox, Town =
@townTextBox, Postcode = '@postcodeTextBox', [Tel Number] = '@telephoneTextBox'  1 1
2 2 Partial Class Update
3 3 Inherits System.Web.UI.Page
4 4
5 5 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
6 6 custIDTextBox.Text = Session("Label2")
7 7
8 8 Dim updatepage As System.Data.DataView = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.DataView)
9 9
10 10 For Each update As Data.DataRow In updatepage.Table.Rows
11 11
12 12 firstnameTextbox.Text = update.Item("First Name").ToString
13 13 lastnameTextBox.Text = update.Item("Last Name").ToString
14 14 addressTextBox.Text = update.Item("Address Line 1").ToString
15 15 townTextBox.Text = update.Item("Town").ToString
16 16 postcodeTextBox.Text = update.Item("Postcode").ToString
17 17 telephoneTextBox.Text = update.Item("Tel Number").ToString
18 18
19 19 Next
20 20
21 21 End Sub
22 22
23 23 Protected Sub updatebutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles updatebutton.Click
24 24
25 25 'Dim parameters firstnameTextBox, lastnameTextBox, addressTextBox, townTextBox, postcodeTextBox, telephoneTextBox
26 26 'Dim UpdateParameters As QueryStringParameter
27 27
28 28 SqlDataSource1.Update()
29 29 SqlDataSource1.UpdateParameters.Add("@CustomerDetails", System.TypeCode.String)
30 30 'SqlDataSource1.UpdateParameters.Add("@Last Name", System.TypeCode.String)
31 31 'SqlDataSource1.UpdateParameters.Add("@Address line 1", System.TypeCode.String)
32 32 'SqlDataSource1.UpdateParameters.Add("@Town", System.TypeCode.String)
33 33 'SqlDataSource1.UpdateParameters.Add("@Postcode", System.TypeCode.String)
34 34 'SqlDataSource1.UpdateParameters.Add("@Tel Number", System.TypeCode.String)
35 35
36 36 'Label2.Text = ("Update successful")
37 37 End Sub
38 38 End Class
39 39
40
41
42
 anyone?

View 2 Replies View Related

Updating By Subtracting?

Nov 5, 2007

Hi,I am currently updating a column in my database table with the value typed into a text box. But it is updating with the new value, rather than taking away the value typed in from the present value of the column. 1. How would i subtract the value typed in away from the current column value?2. I guess I need to check the column value is above 0 before updating, then rebind the control to show new values after the update has happened, incase two people are using it at once. How would this be achived? Thanks for any help!!Jon   P.S.My code is:private bool ExecuteUpdate(int quantity){  SqlConnection con = new SqlConnection();  con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True";  con.Open();  SqlCommand command = new SqlCommand();  command.Connection = con;  TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");  Label labname = (Label)FormView1.FindControl("Label3");  Label labid = (Label)FormView1.FindControl("Label13");  command.CommandText = "UPDATE Items SET Quantityavailable = @qty WHERE productID=@productID";  command.Parameters.Add("@qty", TextBox1.Text);  command.Parameters.Add("@productID", labid.Text); command.ExecuteNonQuery();  con.Close();  return true;}    private bool ExecuteInsert(String quantity)    {        SqlConnection con = new SqlConnection();        con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True";        con.Open();        SqlCommand command = new SqlCommand();        command.Connection = con;        TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");        Label labname = (Label)FormView1.FindControl("Label3");        Label labid = (Label)FormView1.FindControl("Label13");        command.CommandText = "INSERT INTO Transactions (Usersname)VALUES (@User)"+          "INSERT INTO Transactions (Itemid)VALUES (@productID)"+          "INSERT INTO Transactions (itemname)VALUES (@Itemsname)"+          "INSERT INTO Transactions (Date)VALUES (+DateTime.Now.ToString() +)"+          "INSERT INTO Transactions (Qty)VALUES (@qty)"+        command.Parameters.Add("@User", System.Web.HttpContext.Current.User.Identity.Name);        command.Parameters.Add("@Itemsname", labname.Text);        command.Parameters.Add("@productID", labid.Text);        command.Parameters.Add("@qty", TextBox1.Text);        command.ExecuteNonQuery();        con.Close();        return true;    }protected void Button2_Click(object sender, EventArgs e){  TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox;  ExecuteUpdate(Int32.Parse(TextBox1.Text) );}protected void Button2_Command(object sender, CommandEventArgs e)    {        if (e.CommandName == "Update")        {            SqlDataSource1.Insert();        }    }}

View 7 Replies View Related

Updating A Column By The Value Of '1'

Nov 6, 2007

Hi,Its probably simple but.. How do I update a column by just '1'..for example - heres my code:    protected void Button1_Click(object sender, EventArgs e)    {        SqlConnection con = new SqlConnection();        con.ConnectionString = "HiddenConnection";        con.Open();        SqlCommand command = new SqlCommand();        command.Connection = con;        Label productIDLabel = (Label)DataList1.FindControl("productIDLabel");        command.CommandText = "UPDATE Items SET numberclickedin = numberclickedin + 1 WHERE productID=@productID";        command.Parameters.Add("@productID", productIDLabel.Text);        command.ExecuteNonQuery();        con.Close();        command.Dispose();    } As you can see in the bold text, I want to add 1 to the numberclickedin column.. and in my primative way Ive just typed +1What should I use instead?Thanks in advance,Jon 

View 1 Replies View Related

Updating Tables

Jan 19, 2008

Consider i have 2 database namely database1 and database2 . both the databases are in the same server
database1 has a following tables
1.the table "class" has following fields and many more fields. consider 50 fields but for the use of example i have given only three fields name and sample values.     class        studentname           rollno  (table name - class)    8th std      aaaaa                     100
2. the table "Fees" has the following fields  and many more fields. consider 25 field but for the use of example i have gievn only 2 fields name and sample values    rollno              fees         (table name - fees)     100                50000     101                25000
Now i have created the following tables in database2  the table "class" has the following fields only,         class          studentname              rollnothe table "fees" has the following fields only.        rollno           fess  
Question ?please let me know if there is any tool or method . to transfer values from database1 to databse2
 
 
 

View 5 Replies View Related

Updating Using Textbox In VB

Jan 29, 2008

Hello
 How do u update the datafield of a row using buttonClick in vb? I have a details view whereby it will display the username and timeleft once log in. currently the datafield, timeleft on one user in the database is null. I'm using sqldatasource.
Once log in, it will direct to this page where the user enters a code on the textbox and click the enter button. This will cause an update on the user's timeleft. But the code must not be entered to the database.
 For eg. If code = 1111 then 'update timeleft = 60 The timeleft is in minutes. 60 will be stored as double in the user's row in the database. How do i do this?
Please help asap. Thanks! :)

View 3 Replies View Related

Input Box Not Updating

Feb 25, 2008

I have two textboxes on the page...shipdate and duedate.  When the page loads, shipdate has today's date loaded and duedate has a date that's 28 days later than today.  When I change the dates and submit it's not updating in the database instead I'm getting the two dates in pageload.  What am I doing wrong?Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
ShipDateTxt.Text = Today()
DueDateTxt.Text = DateAdd(DateInterval.Day, 28, Today())
End SubProtected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoanRequest.Click
Dim conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainUserConnectionString").ConnectionString)Dim cmd As New Data.SqlClient.SqlCommandWith cmd
.Connection = conn
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "UpdateloanerInfo".Parameters.AddWithValue("@requestorid", Integer.Parse(Request.QueryString("requestorid")))
.Parameters.AddWithValue("@shipdate", ShipDateTxt.Text).Parameters.AddWithValue("@duedate", DueDateTxt.Text)
End With
Here's updateloanerinfo stored procedure:
@requestorid int,@shipdate datetime,@duedate datetime
AS update LibraryRequest
set [shipdate] = @shipdate,[duedate] = @duedate
Where  requestorid=@requestorid

View 3 Replies View Related

Batch Updating?

Mar 28, 2008

Hey guys, I periodically have to update maybe 300 records of the same column.. However, I've been udpating each record one by one.
Is there a way I can do something the following.ID   Name1    john2    chris3    adam4    ben5    steveupdate table1 set name = name where id = ? but have it run through an entire set of these? Is there any way of automating that rather than having to update it manually? Do i need another table with just the id numbers and the column I want to change? or do i need a txt file?

View 6 Replies View Related

Updating Data

Apr 18, 2008

building some kind of ecommerce site.
I want to allow the user to modify the image that he has stored for a product.
The image is stored in a directory, in the table GAMME I only have the image name.
When the user selects a new Image, I first delete the old image in the directory, then save the new image, but what I can't do is to update the table with the new image name, when I write sqldatasource1.update() I have an error "the dictionnary passed with old values is empty"(translated from frengh).
the update statement in sqldatasource1 is: " UPDATE Gamme SET imagename = @imagename, imagesize = @imagesize WHERE (product_ID = @original_product_ID)"
 
on events sqldatasource1.updating I have written:
e.Command.Parameters("@imagename").Value = (FileUpload1.FileName).ToString()
e.Command.Parameters("@taillevignette").Value = FileUpload1.PostedFile.ContentLength
e.Command.Parameters("@original_product_ID").Value = Session("Product_ID").ToString         
 this is not written but the session("product_ID") is the good value
the problem must come from the last lign, but I don't Understand the problem and how to solve it.
 
 

View 1 Replies View Related

Need Help For Updating Values

May 14, 2008

Hi!

I am trying to retrieve and update data. I am retrieving the data into the respective controls such as textboxes. The codes are follow:

Retrieve data - working

Dim sqlConn As New SqlConnection()
sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings("ScheduleConnectionString").ToString()

Dim com As SqlCommand = New SqlCommand("SELECT * FROM Demo_Theatre_DB WHERE ID=" & "@ID", sqlConn)

Dim paramID As New SqlParameter("@ID", SqlDbType.Int)

paramID.Direction = ParameterDirection.Input

com.Parameters.Add(paramID)
paramID.Value = e.Value
sqlConn.Open()
Dim reader As SqlDataReader = com.ExecuteReader()
While reader.Read()
StartTimeTextBox.Text = reader("StartTime")
EndTimeTextBox.Text = reader("EndTime")
CompanyNameTextBox.Text = reader("CompanyName")
PurposeTextBox.Text = reader("Purpose")
AccountManagerTextBox.Text = reader("AccountManager")
PresenterTextBox.Text = reader("Presenter")
ColorDDL.SelectedValue = reader("ColorCode")
StatusRadioButtonList.SelectedValue = reader("Status")
CommentTextBox.Text = reader("Comments")
End While


update the data - NOT WORKING


Dim sqlConn As New SqlConnection()
sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings("ScheduleConnectionString").ToString()

Dim cmd As SqlCommand = New SqlCommand("UPDATE Demo_Theatre_DB SET StartTime = @StartTime, EndTime = @EndTime, CompanyName = @CompanyName, Purpose = @Purpose, AccountManager = @AccountManager, Presenter = @Presenter, ColorCode = @ColorCode, Status = @Status, Comments = @Comments WHERE ID=@ID")

cmd.Parameters.AddWithValue("StartTime", StartTimeTextBox.Text)
cmd.Parameters.AddWithValue("EndTime", EndTimeTextBox.Text)
cmd.Parameters.AddWithValue("CompanyName", CompanyNameTextBox.Text)
cmd.Parameters.AddWithValue("Purpose", PurposeTextBox.Text)
cmd.Parameters.AddWithValue("AccountManager", AccountManagerTextBox.Text)
cmd.Parameters.AddWithValue("Presenter", PresenterTextBox.Text)
cmd.Parameters.AddWithValue("ColorCode", ColorDDL.SelectedValue)
cmd.Parameters.AddWithValue("Status", StatusRadioButtonList.SelectedValue)
cmd.Parameters.AddWithValue("Comments", CommentTextBox.Text)

Try
sqlConn.Open()
cmd.ExecuteScalar()

Catch ex As Exception
InsertMsgLabel.Text = ex.ToString
End Try
End Sub


I am getting the following error whenever I click update button.
"ExecuteScalar: Connection property has not been initialized"

Your help will be appriciated!

Thanks!

View 24 Replies View Related

Updating Textbox?

May 16, 2008

 HelloI have a problem when I want to update my textbox, I have a textbox called Textbox1, when I Insert data from it to database it is working well, even when I Update it WITHOUT SELECT field from database it is working well again,but when I Select [pagename] from database then want to Update it it is not working, nothing happend and in debuging the textbox doesnt have any value. what shoud i do? the value become null?    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        Label1.Text = Request("Id").ToString()        Dim conname As String = ConfigurationManager.ConnectionStrings("IPbrandConnectionString").ConnectionString()        Dim con As New SqlConnection(conname)        Dim sql As String = "SELECT [Id], [pagename] FROM [content] WHERE ([Id] = @Id)"        Dim cmd As New SqlCommand(sql, con)        cmd.Parameters.Add(New SqlParameter("@Id", SqlDbType.Int, 32))        cmd.Parameters("@Id").Value = Label1.Text.ToString()        con.Open()        Dim reader As SqlDataReader = cmd.ExecuteReader()        Do While reader.Read()            TextBox1.Text = reader("pagename")           Loop        reader.Close()        con.Close()    End Sub  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim conname1 As String = ConfigurationManager.ConnectionStrings("IPbrandConnectionString").ConnectionString()        Dim con1 As New SqlConnection(conname1)        Dim sql1 As String = "UPDATE [content] SET [pagename] = @pagename WHERE [Id] = @Id "        Dim cmd1 As New SqlCommand(sql1, con1)        cmd1.Parameters.Add(New SqlParameter("@Id", SqlDbType.Int, 32))        cmd1.Parameters("@Id").Value = Label1.Text.ToString()        cmd1.Parameters.Add(New SqlParameter("@pagename", SqlDbType.VarChar, 50))        cmd1.Parameters("@pagename").Value = TextBox1.Text.ToString()        cmd1.UpdatedRowSource = UpdateRowSource.OutputParameters        Try            con1.Open()            cmd1.ExecuteNonQuery()        Catch err As SqlException            Throw New ApplicationException("Data error.")        Finally            con1.Close()        End Try        Server.Transfer("main.aspx")

View 2 Replies View Related

Updating A Substring

May 29, 2008

 Hi I am trying to update a part of a date string using the following sql statement. Alas, I'm having no joy.cmd.CommandText = "UPDATE tb_bookings SET SUBSTRING(startDate,12,5) = @newStartTime  WHERE requestPackID = @reqPackID";   The date has been saved  in the db in the following format:Fri May 23 17:30:00 GMT+0900 2008 Any idea why this isn't working. Any help much appreciated.Barry 

View 4 Replies View Related

Updating SQL Server From ASP.Net

Jan 23, 2004

I am trying to write a web application for a Karate Association TMADragons.com, that will allow instructors to log on, access data on their schools and update their files.

I have managed to get a handle on retreiving data and displaying fairly wel with data biding, but I am having a lot of trouble giving them an interface to update data.

What I would like to do is have a checkbox on the the grid, and a button to click to change selected records, then call a different page that displays and updates each selected record, one by one.

Right now, I would like to try anything that would allow remote update of the files through the internet. I have spent about $700 for a stack of manuals, but they all show you how to build an interface to retrieve data, not how to update it.

Can anyone point me to a pratical example I can look at?

View 3 Replies View Related

Updating A Record

Nov 17, 2004

Hello, I'm new to SQL, I need to HtmlEncode a column in all my records in a table, how can i construct my sql string? I have the following...

Cmd = "UPDATE articulos SET DescripcionCorta = HtmlEncode(DescripcionCorta) WHERE codigo='x'"

All I need is to Encode my "DescripcionCorta" Field.

Regards.

Roberto.

View 6 Replies View Related

UPDATE Not Updating

May 23, 2005

Hello all,

I've been working on a stored procedure that updates values I have
stored in a table on a SQL Server 2000 db and I'm not sure what kind of
problem I'm having.  I pass the stored procedure the required
parameters, run it, and everything goes fine until I check the db and
no updates have been done.  I've gone back and checked the return
value of command.ExecuteNonQuery and it's '0' so it's not indicating
that anything went wrong.  I've tried updating values that are
already present values that were previously 'Null' and I get the same
result everytime, no update.  Any suggestions?  Below is my
stored procedure

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER        PROCEDURE dbo.UpdateApplication

    (
@1 varchar(9),
@2 varchar(50),
@2_DBA varchar(50),
@3 varchar(25),
@3_other varchar(150),
@4_street1 varchar(100),
@4_state varchar(2),
@4_street2 varchar(100),
@4_zip varchar(10),
@4_city varchar(50),
@5_street1 varchar(100),
@5_state varchar(2),
@5_street2 varchar(100),
@5_zip varchar(10),
@5_city varchar(50),
@6 bit,
@6_web varchar(50),
@7 varchar(15),
@7_percent smallint,
@8 varchar(30),
@8_other varchar(100),
@9 varchar(50),
@9_street1 varchar(100),
@9_state varchar(2),
@9_street2 varchar(100),
@9_zip varchar(10),
@9_city varchar(50),
@10 varchar(50),
@10_interest varchar(50),
@10_street1 varchar(100),
@10_state varchar(2),
@10_street2 varchar(100),
@10_zip varchar(10),
@10_city varchar(50),
@11 varchar(50),
@11_interest varchar(50),
@11_street1 varchar(100),
@11_state varchar(2),
@11_street2 varchar(100),
@11_zip varchar(10),
@11_city varchar(50),
@12_Name varchar(50),
@12_Number varchar(15),
@13_Name varchar(50),
@13_Number varchar(15),
@14_years smallint,
@14_months smallint,
@14_man_years smallint,
@14_man_months smallint,
@15_years smallint,
@15_months smallint,
@15_stories smallint,
@16 bit,
@17 bit,
@18 bit,
@19_company varchar(50),
@19_premium money,
@20 bit,
@20_explain text,
@21_sqft int,
@21_apl_sqft int,
@21_apt_sqft int,
@21_units int,
@21_lro_sqft int,
@22_mon_thurs_o varchar(7),
@22_mon_thurs_c varchar(7),
@22_fri_o varchar(7),
@22_fri_c varchar(7),
@22_sat_o varchar(7),
@22_sat_c varchar(7),
@22_sun_o varchar(7),
@22_sun_c varchar(7),
@23 bit,
@23a_date varchar(10),
@23a_type varchar(50),
@23a_paid money,
@23a_reserved money,
@23a_open bit,
@23b_date varchar(10),
@23b_type varchar(50),
@23b_paid money,
@23b_reserved money,
@23b_open bit,
@23c_date varchar(10),
@23c_type varchar(50),
@23c_paid money,
@23c_reserved money,
@23c_open bit,
@23d_date varchar(10),
@23d_type varchar(50),
@23d_paid money,
@23d_reserved money,
@23d_open bit,
@24 bit,
@25 bit,
@26 bit,
@27 bit,
@28 bit,
@29 bit,
@30 bit,
@31 bit,
@32 bit,
@33 bit,
@34 bit,
@35 bit,
@36 bit,
@37 bit,
@38 bit,
@39 bit,
@39_explain text,
@40 bit,
@40_num smallint,
@40_types varchar(50),
@41 varchar(100),
@42a bit,
@42a_num smallint,
@42a_types varchar(100),
@42a_members smallint,
@42a_others varchar(50),
@42b bit,
@42c_sqft smallint,
@42c_week smallint,
@42d bit,
@42e bit,
@42f bit,
@42f_explain varchar(50),
@42g bit,
@42g_explain varchar(50),
@43a bit,
@43b bit,
@43c bit,
@43d bit,
@43e bit,
@43f bit,
@44 bit,
@44a bit,
@44a_states varchar(150),
@44b smallint,
@44c smallint,
@44d varchar(25),
@44d_explain varchar(50),
@45_food_p money,
@45_food_n money,
@45_alch_p money,
@45_alch_n money,
@45_alch_tr_p money,
@45_alch_tr_n money,
@45_cc_p money,
@45_cc_n money,
@45_opc_p money,
@45_opc_n money,
@45_other varchar(50),
@45_other_p money,
@45_other_n money,
@45_total_p money,
@45_total_n money,
@46a_am smallint,
@46a_am_three smallint,
@46b_ff money,
@46b_mf money,
@46c varchar(50),
@47a bit,
@47b bit,
@47c bit,
@47d smallint,
@48_gen money,
@48_fire money,
@48_prod money,
@48_med money,
@48_eac money,
@48_pers money,
@49 bit,
@49_months varchar(100),
@50 bit,
@50_when varchar(50),
@51 bit,
@51_when varchar(50),
@52 bit,
@53 bit,
@54 bit,
@55 varchar(10),
@56_roof smallint,
@56_elec smallint,
@56_plum smallint,
@56_heat smallint,
@57 bit,
@58 bit,
@58_percent smallint,
@59 varchar(20),
@60 varchar(45),
@61 bit,
@61a varchar(100),
@61a_other varchar(50),
@61a_veg bit,
@61b bit,
@61c bit,
@61c_clean varchar(50),
@61c_date varchar(10),
@61d varchar(3),
@62a varchar(6),
@62b varchar(4),
@62c_value varchar(20),
@62c money,
@62d_build money,
@62d_coins smallint,
@62e_con money,
@62e_coins smallint,
@62f_bus money,
@62f_coins smallint,
@62f varchar(3),
@62g varchar(50),
@63a_ins money,
@63a_out money,
@63b_ins money,
@63b_out money,
@63c money,
@63d smallint,
@63e bit,
@Record int
)

AS
   
UPDATE Application

SET                 
[1]=@1 ,
[2]=@2 ,
[2_DBA]=@2_DBA ,
[3]=@3 ,
[3_other]=@3_other ,
[4_street1]=@4_street1 ,
[4_street2]=@4_street2 ,
[4_city]=@4_city ,
[4_state]=@4_state ,
[4_zip]=@4_zip ,
[5_street1]=@5_street1 ,
[5_street2]=@5_street2 ,
[5_city]=@5_city ,
[5_state]=@5_state ,
[5_zip]=@5_zip ,
=@6 ,
[6_web]=@6_web ,
[7]=@7 ,
[7_percent]=@7_percent ,
=@8,
[8_other]=@8_other ,
[9]=@9 ,
[9_street1]=@9_street1 ,
[9_street2]=@9_street2 ,
[9_city]=@9_city ,
[9_state]=@9_state ,
[9_zip]=@9_zip ,
[10]=@10 ,
[10_interest]=@10_interest ,
[10_street1]=@10_street1 ,
[10_street2]=@10_street2 ,
[10_city]=@10_city ,
[10_state]=@10_state ,
[10_zip]=@10_zip ,
[11]=@11 ,
[11_interest]=@11_interest ,
[11_street1]=@11_street1 ,
[11_street2]=@11_street2 ,
[11_city]=@11_city , [11_state]=@11_state , [11_zip]=@11_zip , [12_Name]=@12_Name , [12_Number]=@12_Number ,
[13_Name]=@13_Name , [13_Number]=@13_Number , [14_years]=@14_years , [14_months]=@14_months , [14_man_years]=@14_man_years ,
[14_man_months]=@14_man_months , [15_years]=@15_years , [15_months]=@15_months , [15_stories]=@15_stories ,
[16]=@16 , [17]=@17 , [18]=@18 , [19_company]=@19_company , [19_premium]=@19_premium , [20]=@20 , [21_sqft]=@21_sqft ,
[21_apl_sqft]=@21_apl_sqft , [21_apt_sqft]=@21_apt_sqft , [21_units]=@21_units , [21_lro_sqft]=@21_lro_sqft ,
[22_mon_thurs_o]=@22_mon_thurs_o , [22_fri_o]=@22_fri_o , [22_sat_o]=@22_sat_o , [22_sun_o]=@22_sun_o ,
[22_mon_thurs_c]=@22_mon_thurs_c , [22_fri_c]=@22_fri_c , [22_sat_c]=@22_sat_c , [22_sun_c]=@22_sun_c ,
[23]=@23 , [23a_date]=@23a_date , [23a_type]=@23a_type , [23a_paid]=@23a_paid , [23a_reserved]=@23a_reserved ,
[23a_open]=@23a_open , [23b_date]=@23b_date , [23b_type]=@23b_type , [23b_paid]=@23b_paid , [23b_reserved]=@23b_reserved ,
[23b_open]=@23b_open , [23c_date]=@23c_date , [23c_type]=@23c_type , [23c_paid]=@23c_paid , [23c_reserved]=@23c_reserved ,
[23c_open]=@23c_open , [23d_date]=@23d_date , [23d_type]=@23d_type , [23d_paid]=@23d_paid , [23d_reserved]=@23d_reserved ,
[23d_open]=@23d_open , [24]=@24 , [25]=@25 , [26]=@26 , [27]=@27 , [28]=@28 , [29]=@29 , [30]=@30 , [31]=@31 ,
[32]=@32 , [33]=@33 , [34]=@34 , [35]=@35 , [36]=@36 , [37]=@37 , [38]=@38 , [39]=@39 , [39_explain]=@39_explain ,
[40]=@40 , [40_num]=@40_num , [40_types]=@40_types , [41]=@41 , [42a]=@42a , [42a_num]=@42a_num , [42a_types]=@42a_types ,
[42a_others]=@42a_others , [42a_members]=@42a_members , [42b]=@42b , [42c_sqft]=@42c_sqft , [42c_week]=@42c_week ,
[42d]=@42d , [42e]=@42e , [42f]=@42f , [42f_explain]=@42f_explain , [42g]=@42g , [42g_explain]=@42g_explain ,
[43a]=@43a , [43b]=@43b , [43c]=@43c , [43d]=@43d , [43e]=@43e , [43f]=@43f , [44]=@44 , [44a]=@44a ,
[44a_states]=@44a_states , [44b]=@44b , [44c]=@44c , [44d]=@44d , [44d_explain]=@44d_explain , [45_food_p]=@45_food_p ,
[45_food_n]=@45_food_n , [45_alch_p]=@45_alch_p , [45_alch_n]=@45_alch_n , [45_alch_tr_p]=@45_alch_tr_p ,
[45_alch_tr_n]=@45_alch_tr_n , [45_cc_p]=@45_cc_p , [45_cc_n]=@45_cc_n ,[45_opc_p]=@45_opc_p ,
[45_opc_n]=@45_opc_n , [45_other]=@45_other , [45_other_p]=@45_other_p , [45_other_n]=@45_other_n ,
[45_total_p]=@45_total_p , [45_total_n]=@45_total_n , [46a_am]=@46a_am , [46a_am_three]=@46a_am_three ,
[46b_ff]=@46b_ff , [46b_mf]=@46b_mf , [46c]=@46c , [47a]=@47a , [47b]=@47b , [47c]=@47c , [47d]=@47d , [48_gen]=@48_gen ,
[48_fire]=@48_fire , [48_prod]=@48_prod , [48_med]=@48_med , [48_eac]=@48_eac , [48_pers]=@48_pers , [49]=@49 ,
[49_months]=@49_months , [50]=@50 , [50_when]=@50_when , [51]=@51 , [51_when]=@51_when , [52]=@52 , [53]=@53 ,
[54]=@54 , [55]=@55 , [56_roof]=@56_roof , [56_elec]=@56_elec , [56_plum]=@56_plum , [56_heat]=@56_heat ,
[57]=@57 , [58]=@58 , [58_percent]=@58_percent , [59]=@59 , [60]=@60 , [61]=@61 , [61a]=@61a , [61a_other]=@61a_other ,
[61a_veg]=@61a_veg , [61b]=@61b , [61c]=@61c , [61c_clean]=@61c_clean , [61c_date]=@61c_date ,
[61d]=@61d , [62a]=@62a , [62b]=@62b , [62c]=@62c , [62c_value]=@62c_value , [62d_build]=@62d_build ,
[62d_coins]=@62d_coins , [62e_con]=@62e_con , [62e_coins]=@62e_coins , [62f]=@62f , [62f_bus]=@62f_bus ,
[62f_coins]=@62f_coins , [62g]=@62g , [63a_ins]=@63a_ins , [63a_out]=@63a_out , [63b_ins]=@63b_ins ,
[63b_out]=@63b_out , [63c]=@63c , [63d]=@63d , [63e]=@63e , [20_explain]=@20_explain

WHERE [Record] = @Record

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

View 11 Replies View Related

Updating A Sql Database From Asp.net

May 25, 2005

Im sorry for how simple this question is im.. brand new at this.I am trying to write a program that will take information entered in 4 txt fields on a webform and populate a sql database with them with a submit button..   Eventually its going to be a updateable phone list for my department but for now im just trying to get the submit button to work.  More then anything i just need a good resourse to read up on it. Thankyou Adam

View 2 Replies View Related

Timestamp When Updating

Oct 4, 2005

Hi world,I would like to know how to maintain a table with a "timestamp" column. I mean a column that automatically set the current datetime when the row is updated.I don't want to go trought my application and set that in the update or insert command. I would like to know if there is a possibility of putting a trigger or something.thx

View 6 Replies View Related







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