Solved

Ucase in ASP.NET in DetailView

Posted on 2006-06-19
13
847 Views
Last Modified: 2008-02-26



I have a Detailview Table linked to a sql database and in the detailview, I have Insert enabled.  My question is, how do I add Ucase as a string in the detailview table to allow all Uppercase letters in a sql field.
0
Comment
Question by:JWFreedom
  • 7
  • 6
13 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16940107
can you be more clear?
You want to UPPERCASE string as data in sql fields (inserted from the detailsview insert mode?)
Or do you want uppercase all characters before inserting in SQL?
ie
my string --> <submit> --> MY STRING --> <insert in SQL>
?
0
 

Author Comment

by:JWFreedom
ID: 16942940
Exactly,,, before it goes to sql,  [text] <insert> [TEXT] in SQL
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16943023
INSERT INTO YourTable(field) VALUES(UCASE(Value))

Hope this'll help
kGenius
0
 

Author Comment

by:JWFreedom
ID: 16944602
Would I put this in the Source code,
0
 

Author Comment

by:JWFreedom
ID: 16944621
This is what the stirng looks like:
 <asp:Parameter Name="PC_Name" Type="String" />
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16944628
You put this in your Insert statement (SQL)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:JWFreedom
ID: 16944669
I'm not sure whee that is,  Remeber, this is a table that is used from ASP.  I did not create a table from scratch,  I used the one provide from Visual Web Developer Express.  So everything is pretty much in ASP


<InsertParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16944684
Can you post your entire <asp:SqlDataSource> tag?
0
 

Author Comment

by:JWFreedom
ID: 16944692
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Inventory.aspx.vb" Inherits="_Default" %>

<!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>FTC Inventory Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <strong>FTC INVENTORY PAGE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            <br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp;&nbsp;
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Detail View" Width="83px"></asp:Label></strong><br />
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
            CellPadding="2" CellSpacing="2" DataKeyNames="ID" DataSourceID="SqlDataSource1"
            Height="50px" Width="501px">
            <Fields>
                <asp:BoundField DataField="Employee" HeaderText="Employee Name (Last, First):" SortExpression="Employee" />
                <asp:BoundField DataField="PC_Name" HeaderText="Computer Name on Domain:" SortExpression="PC_Name" />
                <asp:BoundField DataField="PC_Type" HeaderText="Type of Computer (Laptop, Desktop):"
                    SortExpression="PC_Type" />
                <asp:BoundField DataField="PC_Model" HeaderText="Make and Model of Computer:" SortExpression="PC_Model" />
                <asp:BoundField DataField="Service_Tag_ID" HeaderText="Service Tag ID:" SortExpression="Service_Tag_ID" />
                <asp:BoundField DataField="Express_Service_Code" HeaderText="Express Service Code:"
                    SortExpression="Express_Service_Code" />
                <asp:BoundField DataField="Warranty_Status" HeaderText="Warranty Status (In Days):"
                    SortExpression="Warranty_Status" />
                <asp:BoundField DataField="Memory" HeaderText="Amount of Memory:" SortExpression="Memory" />
                <asp:BoundField DataField="Monitor_Type" HeaderText="Monitor Make and Size:" SortExpression="Monitor_Type" />
                <asp:BoundField DataField="Network_Connectivity" HeaderText="Network Connectivity:"
                    SortExpression="Network_Connectivity" />
                <asp:BoundField DataField="Carrying_Case_Type" HeaderText="Carrying Case/Brand:"
                    SortExpression="Carrying_Case_Type" />
                <asp:BoundField DataField="Miscellaneous" HeaderText="Miscellaneous:" SortExpression="Miscellaneous" />
                <asp:CommandField ShowInsertButton="True" ShowDeleteButton="True" ShowEditButton="True" />
            </Fields>
            <AlternatingRowStyle BackColor="#E0E0E0" />
        </asp:DetailsView>
        <asp:Button ID="Button1" runat="server" Text="VIEW GRID" ToolTip="View all records" />
        &nbsp; &nbsp; &nbsp; &nbsp;<asp:Button ID="Button2" runat="server"
            Text="VIEW DETAIL" ToolTip="View/insert single record" />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:INVENTORYConnectionString3 %>"
            DeleteCommand="DELETE FROM [INVENTORY] WHERE [ID] = @ID" InsertCommand="INSERT INTO [INVENTORY] ([Employee], [PC_Name], [PC_Type], [PC_Model], [Service_Tag_ID], [Express_Service_Code], [Warranty_Status], [Memory], [Monitor_Type], [Network_Connectivity], [Carrying_Case_Type], [Miscellaneous]) VALUES (@Employee, @PC_Name, @PC_Type, @PC_Model, @Service_Tag_ID, @Express_Service_Code, @Warranty_Status, @Memory, @Monitor_Type, @Network_Connectivity, @Carrying_Case_Type, @Miscellaneous)"
            SelectCommand="SELECT * FROM [INVENTORY]" UpdateCommand="UPDATE [INVENTORY] SET [Employee] = @Employee, [PC_Name] = @PC_Name, [PC_Type] = @PC_Type, [PC_Model] = @PC_Model, [Service_Tag_ID] = @Service_Tag_ID, [Express_Service_Code] = @Express_Service_Code, [Warranty_Status] = @Warranty_Status, [Memory] = @Memory, [Monitor_Type] = @Monitor_Type, [Network_Connectivity] = @Network_Connectivity, [Carrying_Case_Type] = @Carrying_Case_Type, [Miscellaneous] = @Miscellaneous WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
       <br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Grid View" Visible="False"
            Width="74px"></asp:Label><br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
            CellSpacing="3" DataKeyNames="ID" DataSourceID="SqlDataSource2" AllowSorting="True" Visible="False">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="Employee" HeaderText="Employee Name" SortExpression="Employee" />
                <asp:BoundField DataField="PC_Name" HeaderText="Computer Name on Domain" SortExpression="PC_Name" />
                <asp:BoundField DataField="PC_Type" HeaderText="Type of Computer" SortExpression="PC_Type" />
                <asp:BoundField DataField="PC_Model" HeaderText="Make and Model of Computer" SortExpression="PC_Model" />
                <asp:BoundField DataField="Service_Tag_ID" HeaderText="Service Tag ID" SortExpression="Service_Tag_ID" />
                <asp:BoundField DataField="Express_Service_Code" HeaderText="Express Service Code"
                    SortExpression="Express_Service_Code" />
                <asp:BoundField DataField="Warranty_Status" HeaderText="Warranty Status" SortExpression="Warranty_Status" />
                <asp:BoundField DataField="Memory" HeaderText="Memory" SortExpression="Memory" />
                <asp:BoundField DataField="Monitor_Type" HeaderText="Monitor Type" SortExpression="Monitor_Type" />
                <asp:BoundField DataField="Network_Connectivity" HeaderText="Network Connectivity"
                    SortExpression="Network_Connectivity" />
                <asp:BoundField DataField="Carrying_Case_Type" HeaderText="Carrying Case Type" SortExpression="Carrying_Case_Type" />
                <asp:BoundField DataField="Miscellaneous" HeaderText="Miscellaneous" SortExpression="Miscellaneous" />
            </Columns>
            <AlternatingRowStyle BackColor="#E0E0E0" />
            <HeaderStyle BackColor="LightCyan" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LABELID#ConnectionString %>"
            SelectCommand="SELECT * FROM [INVENTORY]" DeleteCommand="DELETE FROM [INVENTORY] WHERE [ID] = @ID" InsertCommand="INSERT INTO [INVENTORY] ([Employee], [PC_Name], [PC_Type], [PC_Model], [Service_Tag_ID], [Express_Service_Code], [Warranty_Status], [Memory], [Monitor_Type], [Network_Connectivity], [Carrying_Case_Type], [Miscellaneous]) VALUES (@Employee, @PC_Name, @PC_Type, @PC_Model, @Service_Tag_ID, @Express_Service_Code, @Warranty_Status, @Memory, @Monitor_Type, @Network_Connectivity, @Carrying_Case_Type, @Miscellaneous)" UpdateCommand="UPDATE [INVENTORY] SET [Employee] = @Employee, [PC_Name] = @PC_Name, [PC_Type] = @PC_Type, [PC_Model] = @PC_Model, [Service_Tag_ID] = @Service_Tag_ID, [Express_Service_Code] = @Express_Service_Code, [Warranty_Status] = @Warranty_Status, [Memory] = @Memory, [Monitor_Type] = @Monitor_Type, [Network_Connectivity] = @Network_Connectivity, [Carrying_Case_Type] = @Carrying_Case_Type, [Miscellaneous] = @Miscellaneous WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
   
    </div>
    </form>
</body>

</html>
0
 

Author Comment

by:JWFreedom
ID: 16944999
I am getting an error stating that 'UCASE' is not a recognized function name. I placed the UCase just like this:
InsertCommand="INSERT INTO [INVENTORY] ([Employee], [PC_Name], [PC_Type], [PC_Model], [Service_Tag_ID], [Express_Service_Code], [Warranty_Status], [Memory], [Monitor_Type], [Network_Connectivity], [Carrying_Case_Type], [Miscellaneous]) VALUES (@Employee, (UCASE(@PC_Name)), @PC_Type, @PC_Model, @Service_Tag_ID, @Express_Service_Code, @Warranty_Status, @Memory, @Monitor_Type, @Network_Connectivity, @Carrying_Case_Type, @Miscellaneous)"

Is this wrong
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16952650
Can't you just Ucase when showing the data on the page in your Select statement or ucase in templatefield of your detailsview (ie <%# UCase(Bind("PC_Name")) %> )
So not inserting ucased, but viewing it ucased.

The alternative way is to catch the inserting procedure and changing PC_Name parameter dynamicly...
Let me know if you need the code.

kGenius
0
 

Author Comment

by:JWFreedom
ID: 16955126
I would kind of like to have record saved in SQL as all in Caps.  PC_Name is acctually the Name of the Computer on the domain, so it has to be all caps, and when users go and input there info into this form, they usually place all characters as small caps.  I would like it to store as all caps.  

I want to thank you for your help so far, you guys are great....
0
 
LVL 7

Accepted Solution

by:
kGenius earned 500 total points
ID: 16974251
OK try this
Remove
<asp:Parameter Name="PC_Name" Type="String" />
from you sqldatasource

 in Code-behind
Protected Sub DetailsView1_ItemInserting(ByVal ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs) Handles DetailsView1.ItemInserting

Dim sPcName As String = Ctype(DetailsView1.Rows(1).Cells(1).Controls(0), TextBox).Text
SqlDataSource1.InsertParameters.Add("PC_Name", UCase(sPcName))
SqlDataSource1.Insert()

End Sub

Hope this 'll help
kGenius
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET Web Form Variables being reset 2 26
Convert to Hour/minute textbox and compare 3 53
Not showing JavaScript in the list 5 39
Help with C#, MVC, razor. 6 23
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now