Hard Coding Colum Names In Returned DetailsView Table
Apr 13, 2007
Hi all,
We're selecting data from our database, FirstName, LastName, MobileNumber etc.
We're using the detaials view function to return it in a table upon selection. However all of the variables are returned as they are in the database, ie: without spaces.
We tried putting in spaces by selecting "AS what ever", but MSSQL does not seem to like spaces.
Any ideas?
Thanks
View 2 Replies
ADVERTISEMENT
Jan 10, 2008
I have a variable that is created dynamically that will be used as an input for a sql statement.
When I display the variable in a text box it looks like this:
(PROP_CLASS IN ('" & 100 & "','" & 101 & "' ))
The following works when I hard code the values into the SQL statement:
strSQL = "SELECT * FROM web_transfer WHERE (PROP_CLASS IN ('" & 100 & "','" & 101 & "' )) AND ........."But I get no values returned when I use the variable directly in the sql: strSQL = "SELECT * FROM web_transfer WHERE (PROP_CLASS IN (" & propertyClass & ")) AND ..........." The propertyClass variable is the text string “(PROP_CLASS IN ('" & 100 & "','" & 101 & "' ))“. How do I add this variable to the sql string so that it is recognized. I guess that it is adding some hidden characters. Any help please?? I am a newbie to this, s
View 5 Replies
View Related
Jun 6, 2014
See DDL and sample data below. What would be the easiest way to get the desired output without hard coding the values? Data in both tables may change over time.
DECLARE @num AS TABLE (
Id INT IDENTITY(1, 1)
,Price MONEY
)
DECLARE @range AS TABLE (
Id INT IDENTITY(1, 1)
,Rng MONEY
[code]....
View 7 Replies
View Related
May 25, 2015
using below query to raplace the string values (REPLACE abc with T1223), how to use the query without hard coding.
i want to store the values in another temp table and access in main query.
'abc', 'T1223',
'def', 'T456',
'ghi', 'T789',
'jkl', 'T1011',
'mno', 'T12'
select id,name,
LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(name,
'abc', 'T1223'),
'def', 'T456'),
'ghi', 'T789'),
'jkl', 'T1011'),
'mno', 'T12'))) New_id
from TAB
View 4 Replies
View Related
Jul 30, 2006
Urgent help needed!I moved an application from ASP+ACCESS to ASP+MS SQLSERVER and I havethe following problem:If the join on two tables results on duplicate colum names (whichappear in both tables) I could reference them by using:RECORDSET("TABLENAME.COLUMNAME")However with SQLServer if I try this kind of reference I get an errormessage.How can between two colums with the same name from two differen tables?Thanks in advance!Adam
View 5 Replies
View Related
Apr 17, 2008
I am building reports against our TFS development db.
One of the reports tracks days spent (Dwell Time) in various status categories (eg: New, Assigned, In Development, Hold, etc) for a given "ticket".
For a fixed list of values from {Work Item].System_State, I can send the results (days in Assigned) to the column named (Assigned) for each status for each event in the [Work Item History], and then sum them for each ticket as:
Ticket ID New Assigned InDev etc
1230001 2 0 0 ...
1230001 0 1 2 ....
SUM 2 1 2 ....
However, I have many different Projects, each of which use their own Status names.
I don't want to duplicate the same basic report, if I can avoid it.
How can I name and generate this data for the unique Status list for each Project?
Simplest analog is: name = First(Fields!Status.Value, "TFSdb")
and allows value for a column name (category) as: =IIF(Fields!Status.Value = First(Fields!Status.Value, "TFSdb"), Fields!Days.Value, 0)
However this fails beause:
1. It only delivers the FIRST status value, and,
2. I cannot SUM an expression which is itself an aggregate (using First).
View 4 Replies
View Related
Jul 20, 2005
Hello!I have an MS SQL-server with an database, that runs replication. In thisdatabase there is an table with an columni want to extend; varchar(50)->varchar(60).But I get this error (using design window of Enterprise Manager): Cannotdrop the table 'MytableName' because it is being used for replication.Thanks for helpBjoern
View 1 Replies
View Related
Mar 1, 2015
I am designing a package to export staging tables into a flat file.The names of the tables will be: TableAStaging_YYYYMM and TableBStaging_YYYYMM. As you can see the names of the tables will be changing each month.
The flat files will have similar naming: C:MyPathFlatFileTableAStaging__YYYYMM and C:MyPathFlatFileTableAStaging__YYYYMM.I want to run the package as an sql job in two steps, one for each table.I need to dynamically pass the table names and file names (together with the path) to the IS package.
View 1 Replies
View Related
Jan 22, 2004
Hi
I was wondering if anyone has an idea of how we could find the table names and column names of the tables in our Sql server database at runtime/dynamically given our connection string? Please let me know.
Thanks.
View 5 Replies
View Related
Feb 9, 2012
I'm trying to insert data into a table from two tables into a single table along with a hard coded value.
insert into TABLE1
(THING,PERSONORGROUP,ACCESSRIGHTS)
VALUES
((select SYSTEM_ID from TABLE2 where
AUTHOR IN (select SYSTEM_ID from TABLE2 where USER_ID
=('USER1'))),(select SYSTEM_ID from TABLE2 where USER_ID
=('USER2')),255)
I get the following-
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
Do I need to use a cursor?
View 5 Replies
View Related
Jun 14, 2007
Hi,I have table with three columns as belowtable name:expNo(int) name(char) refno(int)I have data as belowNo name refno1 a2 b3 cI need to update the refno with no values I write a query as belowupdate exp set refno=(select no from exp)when i run the query i got error asSubquery returned more than 1 value. This is not permitted when thesubquery follows =, !=, <, <= , >, >= or when the subquery is used asan expression.I need to update one colum with other column value.What is the correct query for this ?Thanks,Mani
View 3 Replies
View Related
Jan 21, 2004
I'm trying to do an update query that looks like this:
UPDATE
PAEMPLOYEE
SET PAEMPLOYEE.LOCAT_CODE = EMPLOYEE.PROCESS_LEVEL
FROM
PAEMPLOYEE A
JOIN EMPLOYEE B ON A.EMPLOYEE = B.EMPLOYEE
It's erroring out on the Employee prefix B.EMPLOYEE saying:
..."does not match with a table name or alias name used in the query"
Is it wrong or will it cause problems to have a field name the same as the table name?
View 5 Replies
View Related
May 12, 2007
In our SQL Server database we will have a table that will be populated with about 2000 recordsper day. That is 2000 records per day for 5 days per week. Currently the computer we are using has about 50 gigabytesof available hard drive space on it. We are concerned that maybe we will need a bigger hard drive,based solely on the number of records entered into this table per day. The problem is I don'tknow how to calculate how much hard drive space we need. I think I read that using varchar,sql server 2005 really optimizes a database. Here is a typical example of data in ourdatabase. I put dots on three lines between the first and last sample record to justillustrate that there are many records in between.
Basically we only need 8 months of data at a time in the table and then we can purgerecords older than 8 months.Can someone help me approximate how much hard drive space I might need for 8 months of data,given the following sample record in the database?
Sample: -->34.5 4.08 10.6 .0012
Sample Table in my DB just for illustration:
(PPsquare inch) (Diameter) (Weight gm) (coeffOfSatFriction)
34.5 4.08 10.6 .0012...21.7 3.54 6.22 .019
View 4 Replies
View Related
Nov 26, 2007
Hi,
I use sql server management express. I have created a table on my hosts remote database and i want to copy the table (or the data) in some format or other to my hard drive. does anyone have any good ideas how i may do this either through management express or other means.
thanks a lot
nick
View 2 Replies
View Related
Dec 14, 2007
I like to define my procedure parameter type to match a referenced table colum type,
similar to PL/SQL "table.column%type" notation.
That way, when the table column is changes, I would not have to change my stored proc.
Any suggestion?
View 1 Replies
View Related
Oct 18, 2007
Hi all,
I have one table with a column of type 'image'. There are manytypes of files saved in that column (i.e. .Doc,Xls,Pdf,jpg,gif etc.). What I want is, read that files from database and save it in temp folder on d drive of server. Can anyone help me in my problem?
Thanx in advance
View 1 Replies
View Related
Nov 6, 2014
I want to be able to return the rows from a table that have been updated since a specific time. My query returns results in less than 1 minute if I hard code the reference timestamp, but it keeps spinning if I load the reference timestamp in a table. See examples below (the "Reference" table has only one row with a value 2014-09-30 00:00:00.000)
select * from A where ReceiptTS > '2014-09-30 00:00:00.000'
select * from A where ReceiptTS > (select ReferenceTS from Reference)
View 5 Replies
View Related
Apr 18, 2007
Here is the scenario,
I have 2 stored procedures, SP1 and SP2
SP1 has the following code:
declare @tmp as varchar(300)
set @tmp = 'SELECT * FROM
OPENROWSET ( ''SQLOLEDB'', ''SERVER=.;Trusted_Connection=yes'',
''SET FMTONLY OFF EXEC ' + db_name() + '..StoredProcedure'' )'
EXEC (@tmp)
SP2 has the following code:
SELECT *
FROM SP1 (which won't work because SP1 is a stored procedure. A view, a table valued function, or a temporary table must be used for this)
Views - can't use a view because they don't allow dynamic sql and the db_name() in the OPENROWSET function must be used.
Temp Tables - can't use these because it would cause a large hit on system performance due to the frequency SP2 and others like it will be used.
Functions - My last resort is to use a table valued function as shown:
FUNCTION MyFunction
( )
RETURNS @retTable
(
@Field1 int,
@Field2 varchar(50)
)
AS
BEGIN
-- the problem here is that I need to call SP1 and assign it's resulting data into the
-- @retTable variable
-- this statement is incorrect, but it's meaning is my goal
INSERT @retTableSELECT *FROM SP1
RETURN
END
View 2 Replies
View Related
Aug 31, 2007
Hello,
Maybe anyone have done that before?
I have table where i store SOURCE_TABLE_NAME and DESTINATION_TABLE_NAME, there is about 120+ tables.
i need make SSIS package which selects SOURCE_TABLE_NAME from source ole db, and loads it to DESTINATION_TABLE_NAME in destination ole db.
I made such SSIS package. set ole db source data access mode to table or view name variable.
set ole db destination data access mode to table or view name variable. set to variables defoult values (names of existing tables)
but when i loop table names is changed, it reports error, that can map columns, becouse in new tables is different columns.
how to solve that problem?
View 5 Replies
View Related
Apr 10, 2008
How do I use table names stored in variables in stored procedures?
Code Snippetif (select count(*) from @tablename) = 0 or (select count(*) from @tablename) = 1000000
I receive the error 'must declare table variable '@tablename''
I've looked into table variables and they are not what I would require to accomplish what is needed.
After browsing through the forums I believe I need to use dynamic sql particuarly involving sp_executesql. However, I am pretty new at sql and do not really understand how to use this and receive an output parameter from it(msdn kind of confuses me too). I am tryin got receive an integer count of the records from a certain table which can change to anything depending on what the user requires.
Code Snippet
if exists(Select * from sysobjects where name = @temptablename)
drop table @temptablename
It does not like the 'drop table @temptablename' part here. This probably wouldn't be an issue if I could get temporary tables to work, however when I use temporary tables i get invalid object '#temptable'.
Heres what the stored procedure does.
I duplicate a table that is going to be modified by using 'select into temptable'
I add the records required using 'Insert into temptable(Columns) Select(Columns)f rom TableA'
then I truncate the original table that is being modified and insert the temporary table into the original.
Heres the actual SQL query that produces the temporary table error.
Code Snippet
Select * into #temptableabcd from TableA
Insert into #temptableabcd(ColumnA, ColumnB,Field_01, Field_02)
SELECT ColumnA, ColumnB, Sum(ABC_01) as 'Field_01', Sum(ABC_02) as 'Field_02',
FROM TableB
where ColumnB = 003860
Group By ColumnA, ColumnB
TRUNCATE TABLE TableA
Insert into TableA(ColumnA, ColumnB,Field_01, Field_02)
Select ColumnA, ColumnB, Sum(Field_01) as 'Field_01', Sum('Field_02) as 'Field_02',
From #temptableabcd
Group by ColumnA, ColumnB
The above coding produces
Msg 208, Level 16, State 0, Line 1
Invalid object name '#temptableabcd'.
Why does this seem to work when I use an actual table? With an actual table the SQL runs smoothly, however that creates the table names as a variable problem from above. Is there certain limitation with temporary tables in stored procedures? How would I get the temporary table to work in this case if possible?
Thanks for the help.
View 6 Replies
View Related
Jun 20, 2006
I have a strange problem. I have some code that executes a sql query. If I run the query in SQL server query analyzer, I get a set of data returned for me as expected. This is the query listed on lines 3 and 4. I just manually type it into query analyzer.
Yet when I run the same query in my code, the result set is slightly different because it is missing some data. I am confused as to what is going on here. Basically to examine the sql result set returned, I write it out to an XML file. (See line 16).
Why the data returned is different, I have no idea. Also writing it out to an XML file is the only way I can look at the data. Otherwise looking at it in the debugger is impossible, with the hundreds of tree nodes returned.
If someone is able to help me figure this out, I would appreciate it.
1. public DataSet GetMarketList(string region, string marketRegion)2. {3. string sql = @"SELECT a.RealEstMarket FROM MarketMap a, RegionMap b " + 4."WHERE a.RegionCode = b.RegionCode"; 5. DataSet dsMarketList = new DataSet();6. SqlConnection sqlConn = new SqlConnection(intranetConnStr); 7. SqlCommand cmd = new SqlCommand(sql,sqlConn);8. sqlConn.Open();9. SqlDataAdapter adapter = new SqlDataAdapter(cmd); 10. try11. {12. adapter.Fill(dsMarketList);
13. String bling = adapter.SelectCommand.CommandText;//BRG 14. dsMarketList.DataSetName="RegionMarket"; 15. dsMarketList.Tables[0].TableName = "MarketList"; 16. dsMarketList.WriteXml(Server.MapPath ("myXMLFile.xml" )); // The data written to 17. myXMLFile.xml is not the same data that is returned when I run the query on line 3&4 18. // from the SQL query 19. } 20. catch(Exception e) 21. { 22. // Handle the exception (Code not shown)
View 2 Replies
View Related
Sep 14, 2015
I have a function that returns a table from a comma-delimited string.
I want to take this a step further and create a function that will return a set of tablenames in a table based on a 'group' parameter which is a simple integer...1->9, etc.Obviously, what I am doing is not working out.
CREATE FUNCTION dbo.fnReturnTablesForGroup
(
@whichgroup int
)
RETURNS @RETTAB TABLE (
TABLENAME VARCHAR(50)
[code]....
View 9 Replies
View Related
May 25, 2008
Hello,
It is possible to write stored procedures which take table names as parameters; is it also possible to do this with table valued functions?
For example, a simple stored procedure is this:
CREATE PROCEDURE SelectTop(@tableName sysname)
AS
BEGIN
Execute('Select top 10 * from ' + @tableName + ';')
END
I want to be able to do the analogous thing with a table valued function (so that I can query the result set, without having to create a temp table). How should I do this (i.e., pass a tablename as an argument to a table valued function)?
View 11 Replies
View Related
Dec 18, 2007
Hi,I am using detailsview to update my database and got a question regarding datetime format. Here is part of my code:
<asp:TemplateField HeaderText="Project Deadline">
<EditItemTemplate>
<asp:TextBox ID="txtDeadline_edit" runat="server" Text='<%# Bind("pro_app_deadline") %>'></asp:TextBox>
<asp:CompareValidator ID="txtDeadlineedit_validator" runat="server" ErrorMessage="Not a valid date format" ControlToValidate="txtDeadline_edit" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="txtDeadline" runat="server" Text='<%# Eval("pro_app_deadline") %>'></asp:Label>
</ItemTemplate></asp:TemplateField>
Since the format of my parameter 'pro_app_deadline' is datetime, it get stored as YYYY-MM-DD hh:mm:ss in datebase. If I want to validate user's input like above way, it always fails since hh:mm:ss append to YYYY-MM-DD. My question is, is there some way I can avoid hh:mm:ss?
Thanks a lot!
View 2 Replies
View Related
May 14, 2006
Can someone please tell me what I am doing wrong...
I have a simple webform that has contains a GridView and a DetailsView. Once the GridView is populated the user simply selects a record from the list. The DetailsView is them populated with all of the data from the selected record.
The DetailsView is bound to a SQL DataSource/CustomerData. I have made sure that the DV control has the Edit/Update Command listed. The user can click the Edit button and successfully edit the fields but when the user clicks the "Update" button I am getting the following message.
Updating is not supported by data source 'CustomerData' unless UpdateCommand is specified
Why isnt the control handling the Update.
Many Thanks!!!!
T
View 4 Replies
View Related
Jun 11, 2006
Hi,I got another question here:I want to use query like this:SELECT * FROM (sp_lock AS T) WHERE objectID = ...The purpose is that I want to query the result set returned by sp_lockusing derived table, but it doesn't work. Why?Thanks,Baihao--Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
View 2 Replies
View Related
Jun 9, 2007
Hi everybody,I have a little Problem with an update and Detailsview.I have 2 table (tblUser - uid,uName,rId) and (tblRole - rId, rDescription) In my update I don't want to use the roles id, I want to use the roles Description.Via sql I do a update the role to Admin like that UPDATE tblUser
SET rId =
(SELECT rId
FROM dbo.tblRoles
WHERE (rDescription = 'Admin')) But I don't get it to work for the detailsview update
View 4 Replies
View Related
Jul 23, 2007
i get Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".
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.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".
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.
Stack Trace:
[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 ...i am using the Edit feature of the detailsview, seems like the datatype is wrong? ID are int (in my DB, BookingID is int), and also its readonly it should not be updating in the first place right? --------------------------------Any way to debug whats in "new" values? ItemUpdating? how to do it?
View 3 Replies
View Related
Jun 9, 2008
Hi,
Can anyone tell me why my Update attempts are not working? Here is my code:
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
AutoGenerateEditButton="True" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
DefaultMode="Edit">
<Fields>
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
</Fields>
</asp:DetailsView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringListings %>"
SelectCommand="SELECT [City] FROM [Listings]"
UpdateCommand="UPDATE [Listings] Set [City]=@City WHERE [ListingID]=@ListingGuid ">
<UpdateParameters>
<asp:Parameter Name="City" />
<asp:Parameter Name ="ListingGuid" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div></form>
</body>
And here is my code behindProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ListingGuid = Request.QueryString("GUID")
End SubProtected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
Label1.Text = "updated"
Label2.Text = ListingGuidEnd Sub
Please let me know what I am doing wrong?
View 3 Replies
View Related
Mar 6, 2006
Hi
I have a Page with a DetailsView and SqlDataSource. When Editing the DetailsView the Sql;DataSource UpdateCommand does not seem to pick up the @parameters of the form fields. I have used OnItemUpdating to view all Keys/OldValues/NewValues passed into the UpdateCommand but nothing seems to be picked up.
When I place a value into UpdateCommand it updates correctly but does not when I use the form. At this stage I have simplified the code down to typical Master-Details Pages (Separate) using a QueryString to filter the SelectCommand. But nothing seems to work.
Please help! I have wasted so much time trying to resolve this and I am on deadline and need this to work.
Thanks
Dave
View 3 Replies
View Related
May 1, 2006
Hello
Am developing a web site using ASP.net 2.0. I have page to manage the employees information in term of viewing, inserting and updating. The problem is that the updating part doesn't work and it didn't give me any error messages.
My code is as following:
<%@ Page Language="VB" AutoEventWireup="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<script runat="server" >
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
If (Not e.Exception Is Nothing) Then
ErrorMessageLabel.Text = "An error occured while entering this record. Please verify you have entered data in the correct format."
e.ExceptionHandled = True
End If
GridView1.DataBind()
End Sub
Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
GridView1.DataBind()
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub
Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub
Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs)
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub
</script>
<body dir="rtl">
<form id="form1" runat="server">
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
SelectCommand="SELECT DISTINCT [dep_Code], [dep_Name], [BRN_Code] FROM [Departments]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
SelectCommand="SELECT DISTINCT [ID], [Name],[Position], [DEPT_Code] FROM [Employees]
where [DEPT_Code]=@dep_Name">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="dep_Name" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
SelectCommand="SELECT DISTINCT [ID], [Authentication], [Name], [Password], [Position], [DEPT_Code], [Contact] FROM [Employees]
where [ID]=@ID "
UpdateCommand="UPDATE [Employees]
SET
[ID] = @ID,
[Authentication]=@Authentication,
[Name]=@Name,
[Password]=@Password,
[Position]=@Position,
[DEPT_Code]=@DEPT_Code,
[Contact]=@Contact
WHERE [ID] = @ID "
InsertCommand="INSERT INTO [Employees]
([ID], [Authentication], [Name], [Password], [Position], [DEPT_Code], [Contact])
Values (@ID, @Authentication, @Name, @Password, @Position, @DEPT_Code, @Contact) "
>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="ID" Type="Int32" PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Authentication" Type="Int16" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="Position" Type="String" />
<asp:Parameter Name="DEPT_Code" Type="Int32" />
<asp:Parameter Name="Contact" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Authentication" Type="Int16" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="Position" Type="String" />
<asp:Parameter Name="DEPT_Code" Type="Int32" />
<asp:Parameter Name="Contact" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<br />
<br />
أختر القسم :
<asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource1" AutoPostBack="True"
DataTextField="dep_Name" runat="server" DataValueField="dep_Code" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<table >
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 100px; height: 154px" valign="top">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
<asp:BoundField DataField="DEPT_Code" HeaderText="DEPT_Code" SortExpression="DEPT_Code" Visible="False" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>
</td>
<td style="width: 100px; height: 154px" valign="top">
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ID" OnItemUpdated="DetailsView1_ItemUpdated"
DataSourceID="SqlDataSource3" Height="50px" Width="125px" AllowPaging="True" OnItemInserted="DetailsView1_ItemInserted">
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
<asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
<asp:BoundField DataField="Contact" HeaderText="Contact" SortExpression="Contact" />
<asp:TemplateField HeaderText="Department" SortExpression="DEPT_Code" >
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("DEPT_Code") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1"
DataTextField="dep_Name" DataValueField="dep_Code" SelectedValue='<%# Bind("DEPT_Code") %>'>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource1"
DataTextField="dep_Name" DataValueField="dep_Code" SelectedValue='<%# Bind("DEPT_Code") %>'>
</asp:DropDownList>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Authentication" SortExpression="Authentication">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#Eval("Authentication") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList4" runat="server" SelectedValue='<%# Bind("Authentication") %>'>
<asp:ListItem Text="Admin_User" Value="1" />
<asp:ListItem Text="Super_User" Value="2" />
<asp:ListItem Text="Normal_User" Value="3" />
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList5" runat="server" SelectedValue='<%# Bind("Authentication") %>'>
<asp:ListItem Text="Admin_User" Value="1" />
<asp:ListItem Text="Super_User" Value="2" />
<asp:ListItem Text="Normal_User" Value="3" />
</asp:DropDownList>
</InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowInsertButton="True" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
</td>
</tr>
</table>
<asp:Label ID="ErrorMessageLabel" EnableViewState="false" runat="server" />
</form>
</body>
</html>
View 4 Replies
View Related
Jun 5, 2008
Hi to all,
I'm writting code that needs to pass data returned by a SqlDataSource object to another object (user control to graph data)
Query in SqlDataSource object is OK, I've seen data returned by it at a GridView Object but I need to pass that data to an user control that needs a reference to the table that has the data
... What would be the code that do that task ??
I'm new to develop web applications... using Visual Web Developer Express 2008
Help in advance
View 1 Replies
View Related
Apr 12, 2006
i am writing a sproc that calls another sproc. this 2nd sproc returns 3 or 4 rows. i want to be able to insert these rows into a table. this sproc is inside a cursor, as i have to call it many times.
how do i insert the rows that it returns into another table??
View 10 Replies
View Related