Solved

Ucase in ASP.NET in DetailView

Posted on 2006-06-19
13
846 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

20 Experts available now in Live!

Get 1:1 Help Now