Why Is My Update Command Not Working

Feb 18, 2008

hi, i am tryuing to use the gridview as means for the user to be able to edit delete and update columns of the database. however when it is run in the browser it allows the user to edit the fields but when i click on the update button it throws an error. can someone please offer me advice on how i can sort this problem out or provide me with any examples as i cant see what the error is. i used the option in edit columns which allows you to specify you want update delete etc controls added to the gridview. how can i make it so it supports updating? thank you
Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.

Source Error:





An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

View 2 Replies


ADVERTISEMENT

UPDATE Command Not Working

Feb 13, 2007

i am using visual web developer 2005 and SQL Express 2005 and VB as the code behindi have a table called orderdetail and i want to update the fromdesignstatus field from 0 to 1 in one of the rows containing order_id = 2so i am using the following coding in button click event  Protected Sub updatebutton_Click(ByVal sender As Object, ByVal e As System.EventArgs)        Dim update As New SqlDataSource()        update.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString()        update.UpdateCommandType = SqlDataSourceCommandType.Text        update.UpdateCommand = "UPDATE orderdetail SET fromdesignstatus = '1' WHERE order_id = '2'"  End Sub  but the field is not updatedi do not know where i have gone wrong in my coding. i am sure that my database connection string is correctplease help me 

View 1 Replies View Related

Defining Command,commandtype And Connectionstring For SELECT Command Is Not Similar To INSERT And UPDATE

Feb 23, 2007

i am using visual web developer 2005 and SQL 2005 with VB as the code behindi am using INSERT command like this        Dim test As New SqlDataSource()        test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToString()        test.InsertCommandType = SqlDataSourceCommandType.Text        test.InsertCommand = "INSERT INTO try (roll,name, age, email) VALUES (@roll,@name, @age, @email) "                  test.InsertParameters.Add("roll", TextBox1.Text)        test.InsertParameters.Add("name", TextBox2.Text)        test.InsertParameters.Add("age", TextBox3.Text)        test.InsertParameters.Add("email", TextBox4.Text)        test.Insert() i am using UPDATE command like this        Dim test As New SqlDataSource()        test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString()        test.UpdateCommandType = SqlDataSourceCommandType.Text        test.UpdateCommand = "UPDATE try SET name = '" + myname + "' , age = '" + myage + "' , email = '" + myemail + "' WHERE roll                                                         123 "        test.Update()but i have to use the SELECT command like this which is completely different from INSERT and  UPDATE commands   Dim tblData As New Data.DataTable()         Dim conn As New Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated                                                                                Security=True;User Instance=True")   Dim Command As New Data.SqlClient.SqlCommand("SELECT * FROM try WHERE age = '100' ", conn)   Dim da As New Data.SqlClient.SqlDataAdapter(Command)   da.Fill(tblData)   conn.Close()                   TextBox4.Text = tblData.Rows(1).Item("name").ToString()        TextBox5.Text = tblData.Rows(1).Item("age").ToString()        TextBox6.Text = tblData.Rows(1).Item("email").ToString()       for INSERT and UPDATE commands defining the command,commandtype and connectionstring is samebut for the SELECT command it is completely different. why ?can i define the command,commandtype and connectionstring for SELECT command similar to INSERT and UPDATE ?if its possible how to do ?please help me

View 2 Replies View Related

OLE DB Command Not Working

May 29, 2008

Hello,

I've created an ssis package that copies or updates data from a table to another.

Essentially I have

DB source

Lookup

conditional split --> update changed rows ole db command

|
|

write new rows to database ole db command


The write new rows command will not work, VS says it executed fine, but no rows are written to the table

I'm trying to get this package to update the modified rows and write the new rows to the table

I tried a simple

insert into table(a,b)
select a,b from othertable
where a = ?

but this didn't work

I then tried the following command ( this command works if run on SQL server management studio):

Insert into mytable ( a,b)
select CB.a, CB.b
from database_A.dbo.CB CB
left join database_B.dbo.CS CS
on CB.a = CS.a
where CS.a is null and CB.a = ?

The database connection manager points to database_B

The table that I'm trying to insert the data to has a primary key constraint on a.

It's a bit annoying to have to go through this process manually


Any ideas why this isn't working?

TIA

View 6 Replies View Related

ASP Update Method Not Working After A MSDE To MSSQL 2005 Expess Update

Oct 20, 2006

The Folowing code is not working anymore. (500 error)

Set objRS = strSQL1.Execute
strSQL1 = "SELECT * FROM BannerRotor where BannerID=" & cstr(BannerID)
objRS.Open strSQL1, objConn , 2 , 3 , adCmdText
If not (objRS.BOF and objRS.EOF) Then
objRS.Fields("Exposures").Value =objRS.Fields("Exposures").Value + 1
objRS.update
End If
objRS.Close

The .execute Method works fine

strSQL1 = "UPDATE BannerRotor SET Exposures=Exposures+1 WHERE BannerID=" & cstr(BannerID)
objConn.Execute strSQL1

W2003 + IIS6.0

Pls advice?

View 1 Replies View Related

Insert Command Not Working, Help Please

Mar 21, 2008

Hey people im just wondering if someone could help me out with this Insert query im doing from one of the learn asp videos. I have a table called EquipmentBooking and it contains the following fields
 <teachingSession, int,> <staff, char(5),> <equipment, varchar(15),> <bookedOn, datetime,> <bookedFor, datetime,> now im doing the following Insert statement in Visual Studio 2005 when the submit button is clicked but all I get is the catched error exception and I just can working out why. Can someone help? heres the code im using
Dim WebTimetableDataSource As New SqlDataSource()WebTimetableDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("WebTimetableConnectionString").ToString()
WebTimetableDataSource.InsertCommandType = SqlDataSourceCommandType.Text
WebTimetableDataSource.InsertCommand = "INSERT INTO EquipmentBooking (teachingSession, staff, equipment, bookedOn, bookedFor) VALUES (@TeachingDropDown, @StaffDropDown, @EquipmentDropDown, @DateTimeStamp, @DateTextBox)"WebTimetableDataSource.InsertParameters.Add("TeachingDropDown", TeachingDropDown.Text)
WebTimetableDataSource.InsertParameters.Add("StaffDropDown", StaffDropDown.Text)WebTimetableDataSource.InsertParameters.Add("EquipmentDropDown", EquipmentDropDown.Text)
WebTimetableDataSource.InsertParameters.Add("DateTimeStamp", DateTime.Now())WebTimetableDataSource.InsertParameters.Add("DateTextBox", DateTime.Now())
Dim rowsAffected As Integer = 0
Try
rowsAffected = WebTimetableDataSource.Insert()Catch ex As Exception
Server.Transfer("problem.aspx")
Finally
WebTimetableDataSource = Nothing
End Try
If rowsAffected <> 1 ThenServer.Transfer("confirmation.aspx")
End If

View 5 Replies View Related

Insert Command Not Working....

Jan 24, 2004

This is a real head ache. Nothing I do to add a record to my SQL2k Database wil work.

I'm logged into it as "sa".

I've Tried Stored Procedures:

Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As New SqlCommand("AddLender", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure

Dim parameterUserName As New SqlParameter("@UserName", SqlDbType.NVarChar, 100)
parameterUserName.Value = userName
myCommand.Parameters.Add(parameterUserName)

Dim parameterName As New SqlParameter("@Name", SqlDbType.NVarChar, 100)
parameterName.Value = name
myCommand.Parameters.Add(parameterName)

Dim parameterCompany As New SqlParameter("@Company", SqlDbType.NVarChar, 100)
parameterCompany.Value = Company
myCommand.Parameters.Add(parameterCompany)

Dim parameterEmail As New SqlParameter("@Email", SqlDbType.NVarChar, 100)
parameterEmail.Value = email
myCommand.Parameters.Add(parameterEmail)

Dim parameterContact As New SqlParameter("@Contact", SqlDbType.NVarChar, 100)
parameterContact.Value = contact
myCommand.Parameters.Add(parameterContact)

Dim parameterPhone As New SqlParameter("@Phone", SqlDbType.NVarChar, 100)
parameterPhone.Value = Phone
myCommand.Parameters.Add(parameterPhone)

Dim parameterFax As New SqlParameter("@Fax", SqlDbType.NVarChar, 100)
parameterFax.Value = Fax
myCommand.Parameters.Add(parameterFax)

myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()

Return CInt(parameterItemID.Value)

The Sproc.......



CREATE PROCEDURE AddLender
(
@Username nvarchar(100),
@ModuleID int,
@Email nvarchar(100),
@Name nvarchar(100),
@Rep nvarchar(250),
@Phone nvarchar(250),
@Fax nvarchar(250),
@City nvarchar (100),
@State nvarchar(100),
@ItemID int OUTPUT
)
AS
INSERT INTO Lenders
(
Email,
Name,
Rep,
Phone,
Fax,
CIty,
State
)
VALUES
(
@Email,
@Name,
@Rep,
@Phone,
@Fax,
@City,
@state

)
SELECT
@ItemID = @@Identity

GO




I get no Errors... I've run SQLProfiller and I don;t even see it run...

I also tried the method..


Dim strSql As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter

strSql = "Select ItemId,ModuleId,Name,Rep, Email,Phone,Fax,City,State,Address From Portal_Lenders;"

objConnection = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionStringOledb"))
objAdapter = New OleDbDataAdapter(strSql, objConnection)

objAdapter.Fill(objDataSet, "Lenders")

Dim objtable As DataTable
Dim objNewRow As DataRow


objtable = objDataSet.Tables("Lenders")

objNewRow = objtable.NewRow()
objNewRow("ModuleId") = moduleId
objNewRow("Name") = NameField.Text
objNewRow("Rep") = RepField.Text
objNewRow("Email") = EmailField.Text
objNewRow("Phone") = PhoneField.Text
objNewRow("Fax") = FaxField.Text
objNewRow("City") = CityField.Text
objNewRow("State") = Statefield.Text
objNewRow("Address") = StreetAddress.Text

objtable.Rows.Add(objNewRow)


Still no Error or activity in the Pofiller.

Please Help...

View 2 Replies View Related

Command Or Execute Not Working

Mar 11, 2007

Can anybody help me with this command code that stops at the execute and eventually gives timeout.


Dim MM_Cmd, strSQL, strSQL2, strSQL3, strSQL4

Set MM_Cmd = Server.CreateObject("ADODB.Command")
MM_Cmd.ActiveConnection = MM_connAdmin_STRING
strSQL = "update Products_Categories set Depth=NULL, Lineage=''"
MM_Cmd.CommandText = strSQL
MM_Cmd.CommandType = 1
'MM_Cmd.CommandTimeout = 0
MM_Cmd.Prepared = True
MM_Cmd.Execute strSQL
Set MM_Cmd = Nothing

Regards
Amazing

View 2 Replies View Related

ExecuteNonQuery - Add Working/Update Not Working

Jan 7, 2004

I am writing a pgm that attaches to a SQL Server database. I have an Add stored procedure and an Update stored procedure. The two are almost identical, except for a couple parameters. However, the Add function works and the Update does not. Can anyone see why? I can't seem to find what the problem is...

This was my test:


Dim cmd As New SqlCommand("pContact_Update", cn)
'Dim cmd As New SqlCommand("pContact_Add", cn)

Try
cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("@UserId", SqlDbType.VarChar).Value = UserId
cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = TextBox1.Text
[...etc more parameters...]
cmd.Parameters.Add("@Id", SqlDbType.VarChar).Value = ContactId

cn.Open()
cmd.ExecuteNonQuery()

Label1.Text = "done"
cn.Close()

Catch ex As Exception
Label1.Text = ex.Message
End Try


When I use the Add procedure, a record is added correctly and I receive the "done" message. When I use the Update procedure, the record is not updated, but I still receive the "done" message.

I have looked at the stored procedures and the syntax is correct according to SQL Server.

Please I would appreciate any advice...

View 2 Replies View Related

Plz Help...update Value In Multiple Db Table Using Single 'update Command'

Mar 18, 2005

hi,friends

we show record from multiple table using single 'selectcommand'.
like....
---------
select *
from cust_detail,vend_detail
---------

i want to insert value in multiple database table(more than one) using single 'insert command'.
is it possible?
give any idea or solution.

i want to update value in multiple database table(more than one) using single 'update command'

i want to delete value in multiple database table(more than one) using singl 'delete command'
it is possible?
give any idea or solution.

it's urgent.

thanks in advance.

View 2 Replies View Related

SqlDataSource.Select Command Not Working?

May 26, 2007

My compiler says that the line in bold below is illegal. The error msg I'm getting is: No overload for method 'select' takes '0' arguments. How can I correct this error and execute a SELECT?
 protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource2.Select ();
 }
 protected void SqlDataSource2_Selected(object sender, SqlDataSourceStatusEventArgs e)
{string strReadyFirstName = e.Command.Parameters["@FirstName"].Value.ToString();string strReadyLastName = e.Command.Parameters["@LastName"].Value.ToString();
}
 <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [User_ID], [User_Name], [FirstName], [LastName], [Company_Name], [Department_Name] FROM [CompanyDepartment] WHERE ([User_Name] = @User_Name)" OnSelected="SqlDataSource2_Selected">
<selectparameters>
<asp:sessionparameter DefaultValue="TheirUserName" Name="User_Name" SessionField="TheirUserName" Type="String" />
</selectparameters>
</asp:SqlDataSource>

View 1 Replies View Related

Kill Spid Command Not Working

May 19, 2008

Hi
:eek: I have a strange problem on my sql 2000 sp4 server

When I kill a session I gives me

Msg 6101, Level 16, State 1, Line 2
Process ID 61 is not a valid process ID. Choose a number between 1 and 32817.

The process exists in sp_who and sp_who2
it even has an entry in the sysprocesses
this happens with all processes even test ones that we create that are'nt doing anything

any suggections (I have been told to re-install sql 2000 but this is not possible as it is a production server and I will only get maintenance time on sunday's not enough time to rebuild )

View 14 Replies View Related

Backup Command Not Working - Not A Trusted SQL Con

May 13, 2008

Hi there, I'm not exactly sure where to post this question, so I'll post it here.

I have 2 Windows XP machines, not part of a network domain. One of the XP machines is running SQL Server 2005 Express edition, lets call this DB machine. The other machine is just running my application - App machine. As part of my application, I want to be able to do a backup of the database.

The DB machine is also running the application. If I log into my application on the DB machine using SQL Server Authentication, and run the backup it works fine. (It's using the T-SQL BACKUP command). If it log into my application on the App machine, and try to do the backup, I'm getting an error saying that "The user is not associated with a trusted SQL connection". The same user is being used in both scenarios, and this user can update the database fine on the App machine, so it's not really a connection problem, it seems a permission problem. The SQL user I have created is a member of the db_backupoperator role for the required database.

Is anyone aware as to why I would be getting this error?

View 3 Replies View Related

Executing SQL Script From Command Promt Not Working

Dec 30, 2003

Hello
I am trying to execute SQl script from command prom like this :


C:Inetputwwwroot> osql -U sa -P -i MyComics.sql


(uid=sa and pwd=)

and I got the result like this :


[Shared Memory]SQl Server deos not exist or access denied
[Shared Memory]Connection Open (Connect()).



I already check the SQL server , it's running.
what do I do now?

Thanks in advance

View 3 Replies View Related

PRINT Command Not Working For Database Client

Jul 20, 2005

Hello,The PRINT command works fine on Query Analyzer.However, when I used it with other Database Client,eg: Aqua Data Studio, nothing got printed out.Is there a way to make it work?Thanks in advance.

View 3 Replies View Related

Backup Command Not Working - Not A Trusted SQL Connection

May 13, 2008

Hi there, I'm not exactly sure where to post this question, so I'll post it here.

I have 2 Windows XP machines, not part of a network domain. One of the XP machines is running SQL Server 2005 Express edition, lets call this DB machine. The other machine is just running my application - App machine. As part of my application, I want to be able to do a backup of the database.

The DB machine is also running the application. If I log into my application on the DB machine using SQL Server Authentication, and run the backup it works fine. (It's using the T-SQL BACKUP command). If it log into my application on the App machine, and try to do the backup, I'm getting an error saying that "The user is not associated with a trusted SQL connection". The same user is being used in both scenarios, and this user can update the database fine on the App machine, so it's not really a connection problem, it seems a permission problem. The SQL user I have created is a member of the db_backupoperator role for the required database.

Is anyone aware as to why I would be getting this error?

View 7 Replies View Related

What Does The Use Command Do When You Are Working Against A User Instance/attachdb

Jun 5, 2008

I have a script from ASP.NET application services. It can be crated using the aspnet_regsql.exe utility in the 2.0 framework. The beginning of the script contains the following:





Code Snippet SQL


DECLARE @dbname nvarchar(128)
DECLARE @dboptions nvarchar(1024)

SET @dboptions = N'/**/'
SET @dbname = N'databasename'

IF (NOT EXISTS (SELECT name
FROM master.dbo.sysdatabases
WHERE name = @dbname))
BEGIN
PRINT 'Creating the ' + @dbname + ' database...'
DECLARE @cmd nvarchar(500)
SET @cmd = 'CREATE DATABASE [' + @dbname + '] ' + @dboptions
EXEC(@cmd)
END
GO

USE [databasename]
GO
I have a database in the App_Data folder in an ASP.NET website project. It shows up in the Server Explorer. But when I run this script on that database, the output seems fine (No rows affected. (0 row(s) returned) etc) but no tables are actually created in the database I ran it on. The database connection string in the Server Explorer has AttachDbFilename and User Instance=True.

So what exactly happens when SQL Server Express executes the CREATE DATABASE and USE [databasename] in this context? Is it ignored, is there now a new database somewhere on my machine, because the script seems to run fine on SOME database, just not the one expected.

Thanks!

View 1 Replies View Related

Is There A Way To Update Multiple Fields Using UPDATE Command

Oct 19, 2005

UPDATE #TempTableESR SET CTRLBudEng = (SELECT SUM(Salaries) from ProjectBudget WHERE Project = @Project)UPDATE #TempTableESR SET CTRLBudTravel = (SELECT SUM(Travels) from ProjectBudget WHERE Project = @Project)UPDATE #TempTableESR SET CTRLBudMaterials = (SELECT SUM(Materials) from ProjectBudget WHERE Project = @Project)UPDATE #TempTableESR SET CTRLBudOther = (SELECT SUM(Others) from ProjectBudget WHERE Project = @Project)UPDATE #TempTableESR SET CTRLBudContingency = (SELECT SUM(Contingency) from ProjectBudget WHERE Project = @Project)above is the UPDATE command i am using in one of my stored procedures. I have to SELECT from my ProjectBudget table 5 times to update my #TempTableESR table. is there an UPDATE command i can use which would let me update multiple fields in a table using one SELECT command?

View 1 Replies View Related

Reporting Services :: Command Line Install Option Not Working

Oct 25, 2011

I am trying to push the install for ReportBuilder 3.0 and am having an issue with the REPORTSERVERURL option for installing via command line.I have a batch file that works fine, however when I launch the app it does not have a report server configured. I have verified I can connect to my report server if I enterĀ it manually.

View 3 Replies View Related

Solution: T-SQL Execution Command Line Utility Has Stopped Working

Jan 19, 2008

Reinstalling SQL Express did the trick

Thought this might help others..

View 2 Replies View Related

Update Command Does Nothing

Aug 10, 2006

I have a database on a server that im trying to update using asp.net.  I tested this on another server and everything worked perfectly.  The test system was set up where the website is hosted.  But the live system is placed on a different server than the webpage.  Does that make a difference? 
Test System
Client -> Website/database
Live System:
Client -> website -> database
I created a user account to use when accessing the database on the live system because i read the double hop causes problems.  By using that account i can access and view the data.  But whenever i update it nothing happens.  NO ERROR either.  It works perfectly but does nothing.  Anyone have any ideas please?!?!?!

View 2 Replies View Related

Update SQL Command

Dec 10, 2007

Hi all, just need a LITTLE help here.  I am very close, I know I am, but just can't seem to fit the last piece in on this.  I have a page that shows current data for a customer and allows you to make changes to the data, then I have a button to push to update the system.  If I hard-code in a value in place of '@Pf_Value' it will update that value, so I know my where is working, just SOMETHING missing in syntax on the set statement or something wrong on my cmd.parameters statement.  Any help would be great!!Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateButton.Click
Dim sql As String = "update CustomerPOFlexField set [Pf_Value] = @Pf_Value where Pf_property = 'Attrib1' and Pf_CustomerNo = @CustomerNo"Dim newc As String = NewCustomer.Text
Using conn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("HCISDataConnectionString").ConnectionString)Dim cmd As New SqlCommand(sql, conn)
cmd.Parameters.AddWithValue("@CustomerNo", DropDownlist1.SelectedValue)cmd.Parameters.Add(New SqlParameter("@Pf_Value", TextBox2.Text))
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Sub
Thanks,
Randy

View 16 Replies View Related

SQL Update Command

Jan 8, 2008

Hi all,
Im working in VB web application.Im having some values in some textbox and trying to update it using update command and its not working for me... I used ExecuteNonQuery statement after that. The alert message after that is working for me. But the values i changed in textbox in not updating in my database.
What could be wrong?          cid = lbcid.Text
cname = txtname.Text
contactname = txtconame.Text
tele = Val(txttele.Text)
mob = Val(txtmob.Text)
email = txtemail.Text
genmess = txtgen.Text cmd = New SqlCommand("Update CompanyDetails set CompanyName='" & cname & "',ContactName='" & contactname & "',Telephone=" & tele & ",Mobile=" & mob & ",Generalmess='" & genmess & "',Email='" & email & "'where CompanyId= '" & cid & "'", con)


con.Open()
cmd.ExecuteNonQuery()
Response.Write("<script>alert('Updated')</script>")
 

View 5 Replies View Related

Update Command Help

Nov 5, 2007

I'm using SQL Server Management Studio to do an extremely simple table update (I thought). I wish to fill a newly added table field with a value, however I didn't do this before... What I do is:


UPDATE _t_Computerhuys_MSCRM.dbo.ContactExtensionBase

SET New_Test = "Testvalue"


However then I get the errormessage:

Msg 207, Level 16, State 1, Line 2

Invalid column name 'Testvalue'.


Apparently what I see as a value is being looked at as a column name. I guess it has to do with syntax, but I can't find what's wrong. How to solve?

View 1 Replies View Related

Update Not Working Using VB

Jan 27, 2008

Hello  Just having an issue with my code not updating my tables.  Fairly new to asp so its frustrating me that its not working Here is my code  1 Protected Sub btnAddBusDetails_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddBusDetails.Click
2 Dim datasource As New SqlDataSource()
3 datasource.ConnectionString = ConfigurationManager.ConnectionStrings("insolvency_dbConnectionString").ToString()
4
5 datasource.UpdateCommand = "Update PrincipalContact set [princName] = @Name, [princPosition] = 'The man', [princContactNumber] = 'At home' Where ([username] = @userName);"
6 datasource.UpdateCommandType
7 datasource.UpdateParameters.Add("userName", My.User.Name)
8 datasource.UpdateParameters.Add("Name", Principal_Name.Text)
9 datasource.UpdateParameters.Add("Position", Principal_Position.Text)
10 datasource.UpdateParameters.Add("Contact", Principal_Contact.Text)
11 datasource.Update()
12
13
14 Dim datasource2 As New SqlDataSource()
15 datasource2.ConnectionString = ConfigurationManager.ConnectionStrings("insolvency_dbConnectionString").ToString()
16
17 datasource2.UpdateCommand = "Update Firm set [insolvencyPractitioner] = @insolvencyPractitioner, [companyName] = @companyName, [tradingAs] = @tradingAs, [businessDescription] = @businessDescription, [principalAddress] = @principalAddress, [tradingStatus] = @tradingStatus, [numberOfEmployees] = @numberOfEmployees, [locationsByState] = @locationsByState Where ([userName] = @userName);"
18 datasource2.UpdateParameters.Add("userName", My.User.Name)
19 datasource2.UpdateParameters.Add("insolvencyPractitioner", Insolvency_Practitioner.Text)
20 datasource2.UpdateParameters.Add("companyName", Company_Name.Text)
21 datasource2.UpdateParameters.Add("tradingAs", Trading_As.Text)
22 datasource2.UpdateParameters.Add("businessDescription", Description_of_Business.Text)
23 datasource2.UpdateParameters.Add("principalAddress", Principal_Address.Text)
24 datasource2.UpdateParameters.Add("tradingStatus", Trading_status.Text)
25 datasource2.UpdateParameters.Add("numberOfEmployees", Number_of_Employees.Text)
26 datasource2.UpdateParameters.Add("locationsByState", Location_by_state.Text)
27
28 datasource2.Update()
29
30 Response.Redirect("~/Default.aspx")
31
32
33
34 End Sub No errors are occurring and when I replace the parameters with actual text it works.eg. Update Firm set [insolvencyPractitioner] = @insolvencyPractitioner, [companyName] = @companyName .... to Update Firm set [insolvencyPractitioner] = 'Luke', [companyName] = 'A Company' ..... Not sure why this is happening. Can someone please give me a hand. Thanks  

View 5 Replies View Related

UPDATE Not Working

Mar 19, 2000

I have a table and I want to update it with data that is available in a
different table, the Master table contains a field called RegID and the other table also has RegId - I am bombing out with this UPDATE QUERY :

UPDATE trainee
SET tra_HomePhone = phone$.EPhoneH,
tra_areaHomePhone = phone$.EPhoneHA,
tra_workPhone = phone$.EPhoneW,
tra_areaWorkPhone = phone$.EPhoneWA,
tra_postcode = phone$.EAddressHP
WHERE trainee.tra_regId = phone$.regID

Any reason why this is not working? Thanks in advance for any help.

Anthony

View 2 Replies View Related

Sql Update With Command.Parameters

Oct 10, 2006

 Im looking for example code to make a sql update... I want to use command.Parameters and variables from text boxes and i'm unsure how to do this...  Please help. This code below doesn't work but it is an example of what i've been working with..  <code>     {               string conn = string.Empty;            ConnectionStringsSection connectionStringsSection = WebConfigurationManager.GetSection("connectionStrings") as ConnectionStringsSection;            if (connectionStringsSection != null)            {                ConnectionStringSettingsCollection connectStrings = connectionStringsSection.ConnectionStrings;                ConnectionStringSettings connString = connectStrings["whowantsConnectionString"];                conn = connString.ConnectionString;                using (SqlConnection connection = new SqlConnection(conn))                using (SqlCommand command = new SqlCommand("UPDATE users SET currentscore=5)", connection))                {                    updateCommand.Parameters.Add("@currentscore", SQLServerDbType.numeric, 18, "currentscore");                    connection.Open();                    command.ExecuteNonQuery();                    connection.Close();                }            }        }</code>   

View 3 Replies View Related

Question Regarding Using The Sql Update Command.

Jul 10, 2007

Here I have the following command
Dim dtNow As DateTime = DateTime.NowSqlDataSource1.UpdateCommand="Update [db] Set [LW]='TRUE', LWD=dtnow Where [PK]=@PK"What I was ttrying to accomplish was , in my grid view, when someone clicks update, it would automatically set LW to true and set LWD to today's date. No user intervention required. However, I figured the above script would not work. What would I have to do to make LWD = dtnow? I do not want to give the user the option to update anything.
 

View 3 Replies View Related

Help With Booleans With UPDATE Command.

Jul 26, 2007

Hello, I'm using a Gridview to display a list of servers.  Each server has a column in a table called "Enabled."  I want to create a button that is supposed to toggle the value called "Enabled."  I am able to make the button either to set Enabled to true or false, but I don't know how to make it toggle.  Here is the command:UpdateCommand="UPDATE [ServerStatus] SET [Enabled] = 1 WHERE [ServerName] = @ServerName" The button is a buttonfield in the gridview:<asp:ButtonField ButtonType="Button" CommandName="Update" HeaderText="Toggle" ShowHeader="True" Text="Toggle" /> Does anyone know the syntax, or a way to make the button set Enabled to true when it is false, and false when it is set to true? 

View 2 Replies View Related

Problem With Update Command

Aug 2, 2007

Hi,i try to update field 'name' (nvarchar(5) in sql server) of table 'mytable'.This happens in event DetailsView1_ItemUpdating with my own code.It works without parameters (i know, bad way) like this:SqlDataSource1.UpdateCommand = "UPDATE mytable set name= '" & na & "'"But when using parameters like here below, i get the error:"Input string was not in a correct format"Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdatingSqlDataSource1.UpdateCommand = "UPDATE mytable set name= @myname"SqlDataSource1.UpdateParameters.Add("@myname", SqlDbType.NVarChar, na)SqlDataSource1.Update()End SubI don't see what's wrong here.Thanks for helpTartuffe

View 2 Replies View Related

How To Use Update Command At Sqldatasouce

Sep 24, 2007

 hello all..,i have problem in update sqldatasource,  my code like that:me.sqldatasource.updateparameter(index).defaultvalue=valueme.sqldatasource.update()it can not update data, why?but if i use insert or delete like:me.sqldatasource.insertparameter(index).defaultvalue=valueme.sqldatasource.insert()me.sqldatasource.deleteparameter(index).defaultvalue=valueme.sqldatasource.delete()it can work for insert and delete data...can anyone give me update command code in sqldatasouce? plsss...thx...  

View 11 Replies View Related

SQL Update Command Fails

Jan 5, 2008

 
I have the code as fallows to update my SQL data ;Sub Kaydet(ByVal TickerKod As String, ByVal op1 As Double, ByVal op2 As Double, ByVal op3 As Double, ByVal op4 As Double, ByVal op5 As Double, ByVal op6 As Double, ByVal op7 As Double, ByVal mov1 As Double, ByVal mov2 As Double)
'Dim nop1 As Decimal = FormatNumber(Replace(op1, ",", "."), 2)Dim mysource As New SqlDataSource
mysource.ConnectionString = ("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Stock.mdf;Integrated Security=True;User Instance=True")mysource.UpdateCommand = ("UPDATE StockParametre SET OPT1 = " & FormatNumber(op1, 2) & ", OPT2 = " & FormatNumber(op2, 2) & ", OPT3 = " & FormatNumber(op3, 2) & ", OPT4 = " & FormatNumber(op4, 2) & ", OPT5 = " & FormatNumber(op5, 2) & ", OPT6 = " & FormatNumber(op6, 2) & ", OPT7 = " & FormatNumber(op7, 2) & ", MOVY = " & FormatNumber(mov1, 2) & ", MOVD = " & FormatNumber(mov2, 2) & " WHERE (Stock = '" & TickerKod & "')")
mysource.Update()Response.Write(mysource.UpdateCommand & "<br>")
End Sub
When I call this code inside of Virtual Web Developer it functions perfect and updates the data..There is no problerm
But when I call it like http:// .......myip/updatedata.aspx then I have the error " System.Data.SqlClient.SqlException: Incorrect Syntax near 32
I  see that 32 is the value inside the update command like SET OPT1=107,32, OPT2=25,00, ........and so on Where do I make wrong ?
Thanks

View 4 Replies View Related

Update Command Syntax ...

Feb 3, 2008

Hi here's a bit of code. What am I doing wrong here?  Visual Studio isn't even accepting the Set word on line 56. It deletes it everytime.  What am I doing wrong here? Why is Visual studio putting the parenthese around the table name in 55? I generated an update query for my Websitetableadapter. Here it is:
UPDATE [tblWebSite] SET [Rating] = @Rating, WHERE (([WebSiteID] = @Original_WebSiteID))
How do I use this to update the Rating column after I've done my calculation below?

1    Imports RatingsTableAdapters2    3    4    Partial Class admin_ratings5        Inherits System.Web.UI.Page6    7        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load8            Dim I As Integer = 09            Dim J As Integer = 010           Dim Rating As Integer11           Dim Rate As Decimal12           Dim tblwebsiteAdapter As New tblWebSiteTableAdapter13           Dim tblWebsite As ratings.tblWebSiteDataTable14           tblWebsite = tblwebsiteAdapter.GetData()15           For Each tblwebsiteRow As ratings.tblWebSiteRow In tblWebsite16               Rate = 017               Dim tblLinkAdapter As New tblLinkTableAdapter18               Dim tblLink As ratings.tblLinkDataTable19               Dim tblLinkTot As ratings.tblLinkDataTable20               tblLink = tblLinkAdapter.GetSuccessfulExchanges(tblwebsiteRow.WebSiteID)21               tblLinkTot = tblLinkAdapter.GetTotalLinks(tblwebsiteRow.WebSiteID)22               For Each tbllinkRow As ratings.tblLinkRow In tblLink23                   If tbllinkRow.LinkID < 1 Then24                       I = 0.125                   Else : I = I + 126                   End If27               Next28               If I <> 0 Then29                   For Each tbllinktotrow As ratings.tblLinkRow In tblLinkTot30                       If tbllinktotrow.LinkID < 1 Then31                           J = 0.132                       Else : J = J + 133                       End If34                   Next35               End If36               If I <> 0 And J <> 0 Then37   38                   Rate = I / J39                   If Rate <= 0.3 Then40                       Rate = 041                   End If42                   If Rate <= 0.5 Then43                       Rate = 144                   End If45                   If Rate <= 0.65 Then46                       Rate = 247                   End If48                   If Rate <= 0.75 Then49                       Rate = 350                   End If51               End If52   53               Response.Write(tblwebsiteRow.WebSiteID & " " & tblwebsiteRow.SiteURL & " Rating: " & Rate & "54               I = 055               J = 056               Update(tblWebsite)57               Rating = Rate58               where(tblwebsiteRow.WebSiteID <> 0)59           Next60       End Sub61   End Class 

View 34 Replies View Related







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