Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 870
  • Last Modified:

Ucase in ASP.NET in DetailView




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
JWFreedom
Asked:
JWFreedom
  • 7
  • 6
1 Solution
 
kGeniusCommented:
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
 
JWFreedomAuthor Commented:
Exactly,,, before it goes to sql,  [text] <insert> [TEXT] in SQL
0
 
kGeniusCommented:
INSERT INTO YourTable(field) VALUES(UCASE(Value))

Hope this'll help
kGenius
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JWFreedomAuthor Commented:
Would I put this in the Source code,
0
 
JWFreedomAuthor Commented:
This is what the stirng looks like:
 <asp:Parameter Name="PC_Name" Type="String" />
0
 
kGeniusCommented:
You put this in your Insert statement (SQL)
0
 
JWFreedomAuthor Commented:
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
 
kGeniusCommented:
Can you post your entire <asp:SqlDataSource> tag?
0
 
JWFreedomAuthor Commented:
<%@ 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
 
JWFreedomAuthor Commented:
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
 
kGeniusCommented:
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
 
JWFreedomAuthor Commented:
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
 
kGeniusCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now