DataSource Controls :: How To View The Command.parameters.items
Feb 3, 2010How do I view my parameters items ?
I tried this but got this error
[code]....
How do I view my parameters items ?
I tried this but got this error
[code]....
I would like to use a command parameter to concatonate two fields
protected void Notes0_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
e.Command.Parameters["Comments"].Value = Eval("LeadID")&" "&Eval("TextBox1");
}
Where the leadID is based on a query string and comments are entered in textbox1
Iam a newbie in Linq to Sql. I have some problems with my deleting items function. assemble the code together:I must have the following code accumulated.
[Code]....
I want to issue an INSERT command for an SQL Server table using DataAdapter without first issuing a SELECT command. Could anybody send me lines of code to handle this? Also how do i manage INSERT into selective table columns (I have 10 columns but i only want to update 2 of them)?
View 2 RepliesI have a asp.net gridview control on my page with several fields and a couple of command fields. However, the update command is giving me problems.
Here is what works. The update command works provided I put straight text into the textboxes that appear. I even have one field that contains a dropdown list which works fine.
Here's the problem. I have two fields that need to access their value programmatically. These fields will reflect the current datetime and the current loggedin user from active directory. I have already created public strings in the C# code.
When I run the edit command on the asp form the grid uses one "DataKeyNames" element. With this the grid can update the selectedrow. However, I haven't been able to access it programmatically in the C# code. I can access the selectedrow in the "selectedindexchanged" event but then I am not able to update my fields in the gridview itself. So, part one of my question is how to I access the "DataKeyNames" properties of a gridview control.
if I can't access the "DataKeyName" property perhaps I could set the label nested within the gridview to the "myCurrentUser()" public string. I am inserting my code to hopefully make this clearer.
I am using ODBC command and adding parameters to it. But it always keeps on saying procedure proc_Update expects a parameters @id which was not supplies ( this errors comes for all the paramters that I add).
Here is my code:
[Code]....
When appending parameters to an ADODB.Command should the parameters add to the command text. When I get to the point where it sends to the database the command text of the adodb.command is "{ call PKG_WORKPLAN.ADD_PROJECT(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }"
I then get a ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 1 error. I think i may be getting it from the question mark.
Also is there any way to what sql is inserted if that isn't it.
here is my code for selectiong some records from db table
string strSql = "select * from mtblNBD where SentTo=@SentTo and InternalStatus Is NULL order by DeadLine desc";
SqlCommand com = new SqlCommand(strSql, con);
com.Parameters.Add("@SentTo", SqlDbType.NVarChar, 50).Value = (string)Session["uname"];
here I am using parameters for SenTo field but not for NULL so it is ok... or should I use parameters for this field where value is NULL , if yes then how can I use parameter for this
The grid view row command does not execute on my production environment. This is a intermittant issue. I am not able to reproduct the exact steps but it does occur too often.
I have a load balanced environment with 2 identical servers in the farm. The servers are running on IIS 7.5
The other scenario in which I observe this is when the session times out. In that case the grid view events are lost. But this scenario is not a priority for me. I need to resolve the first scenario.
Any help on this or some useful links on "Understanding the session" or "understanding the complete event firing and execution" is welcome.
An update: we are overriding the PageStatePersister as:
[Code]....
I have a grid view with a number of columns in Page1.aspx.The last column is a template field with a button.
View 2 RepliesI am using AS 400 OLEDB with .NET. It uses '?' instead of '@param to bind parameters with a commandNow there is a situation where the command is like
SELECT ...
FROM
(SELECT ...
ROW_NUMBER() OVER(ORDER BY ColumnName) as RowNum
FROM Employees e
) as DerivedTableName
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1
Now my command becomes
SELECT ...
FROM
[code]...
I want to know how I could fix the following. I essentially have two almost identical SQL functions and want to combine them into one. The only difference between the two functions is the SQL Command text that is being used. Here is a brief idea of what I have unsuccessfully tried thus far:
[Code]....
I receive no compilation errors, but the exception is thrown and table is not filled. I have a feeling that I am overlooking something obvious.
I want to use parameter in SQL command, Which the following code is better and why?
string id= getId();
SqlCommand cmd1 = cn1.CreateCommand();
cmd1.CommandText = " INSERT INTO std(idStd) VALUES (idStd=id) ";
cmd1.ExecuteNonQuery();
string idF = getId();
SqlCommand cmd1 = cn1.CreateCommand();
cmd1.CommandText = " INSERT INTO std(idStd) VALUES (idStd=@id) ";
cmd1.Parameters.AddWithValue(@id, idF);
cmd1.ExecuteNonQuery();
No matter what I do I keep getting the error that my input string is not valid and that the system cannot convert a string to a double. I have a table with two fields, both are defined as nvarchar(25). My command text is:INSERT INTO OtherProducts VALUES ('Sample','Test') am using Visual Web Developer. This is as simple as it gets. I have tried parameters as well.
View 10 RepliesI have a package already created that inserts into a few tables but am having trouble cpoming up with the code to append the parameters from the the form to the command.
View 1 Repliesi m using these command for backup and restore sql database
BACKUP DATABASE [db_report] TO
DISK =N'db_report.bak'
WITH NOFORMAT, NOINIT, NAME = N'Report-Full Database Backup',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
RESTORE DATABASE [db_report]
FROM DISK = N'db_report.bak'
WITH FILE = 1,
MOVE N'db_report' TO N'C:db_report.mdf',
MOVE N'db_report' TO N'C:db_report.ldf',
NOUNLOAD, STATS = 10
but i want to set backup drive name with today date and time yani my i will set drive D:db_report010320100910am if u will see theres is db_reportMonth(01) Day(03) Year(2010) Time(09:10am) and when i want to restore then ask me which one u want to get restore
given below is the simple update string am using to update my database...
string q = "update register set fname='" + TextBox1.Text +
"',lname='" + TextBox2.Text +
"',gender='" + gender +
"',edu='" + TextBox3.Text +
"' where username='"+check +"'";
cmd.ExecuteNonQuery();
SqlCommand cmd =
new
SqlCommand(q, cn);
but it is not working...database is not getting updated...why?
Cannot open backup device 'C:Program FilesMicrosoft SQL ServerMSSQLBACKUPdatabasename.bak'. Device error or device off-line. See the SQL Server error log for more details.RESTORE DATABASE is terminating abnormally.
View 1 RepliesAre they any special Insert Paramters I shoud/need to use on a formView. I currently have the below datasource but when submitted it only inserts <NULLS> intot he required table.
[Code]....
The fields that aren't being inserted are already pre-populated via the following used FormViews:
[Code]....
I'm using Visual Studio 2008, and when I select/highlight something in design view and switch to source view it does not highlight and scroll to the selected item. This makes it really hard to change stuff in source view, and it's very inconvenient at worst
View 2 RepliesCan I use one SQL command to call many sprocs ?
I would then use the returned data to create a dataset table like I did with one SPROC in this code :
[Code]....
[Code]....
I have the below code in my project..however its giving me an error on the update(bolded line)..please help me on this..
Private Sub ChangePassword1_ChangedPassword(ByVal sender As Object, ByVal e As System.EventArgs) Handles ChangePassword1.ChangedPassword
lblTempPassword.Text = ChangePassword1.NewPassword.ToString
CustomerName.Text = CType(Session("UserName"), String)
Dim FV1Updobjconn As Data.SqlClient.SqlConnection
FV1Updobjconn = New Data.SqlClient.SqlConnection()
FV1Updobjconn.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBconnectionString1").ConnectionString
FV1Updobjconn.Open()
Dim dtUpdating As New Data.DataTable()
Dim sqlUpdating As String = "UPDATE [SuperAdmin] SET [TempPasswd]= @SU2TempPasswd, [TempPwd]=@CU2TempPwd WHERE ([CustomerName] = [@CU2CustomerName])"
Dim cmdUpdating As New Data.SqlClient.SqlCommand(sqlUpdating, FV1Updobjconn)
cmdUpdating.Parameters.AddWithValue("@SU2UserId", UserIDValue.Text)
cmdUpdating.Parameters.AddWithValue("@SU2TempPasswd", lblTempPassword.Text)
cmdUpdating.Parameters.AddWithValue("@CU2TempPwd", False)
cmdUpdating.ExecuteNonQuery().... I get an error here saying..INVALID COLUMN "CU2CustomerName"
' Dim adUpdating As New Data.SqlClient.SqlDataAdapter(cmdUpdating)
' adUpdating.Fill(dtUpdating)
' Get the values needed to be passed on
' CtSUCompanyName.Text = dtUpdating.Rows(0)("CompanyName").ToString()
' CtSUCatPurch.Text = dtUpdating.Rows(0)("CategoriesPurchases").ToString()
FV1Updobjconn.Close()
End Sub
protected void Page_Load(object sender, EventArgs e)
View 7 RepliesI have created a Dataset object (XSD file) whithin it there is a procedure called InsertWebsite.
In my code, I call this like this:
[Code]....
When I execute the commans it retrievs value "1" which is not the actual ID genereted by Insert event.....
How can I retrieve this ID and stll using the current design?
I have a detailsview which I am populating using a SQLDATASOURCE, which is bound to a table in a SQL db. Because the number of columns in the table will change, I am using SELECT * from [TABLENAME] to populate the view, this works fine.
My problem is that I need to also be able to update the table and I thought the best way was to generate the updatecommand in the code behind. This is no problem, code is as follows:
[Code]....
But the next stage is to create the relevant parameters for the update command. Does anybody have any thoughts on this? All of the information I have found for the updateParamater reference knowing the final value.
What I really need to do is the code behind equivalent of
<asp:Parameter Name="PARAMETERNAME" Type="Int32" />
Not sure whether this is possible.