Adding Two Reportitems In Different Scoepes
Apr 28, 2008Hi All,
Is there anyway that I can add two reportitems which are in different scopes?
Thanks
Hi All,
Is there anyway that I can add two reportitems which are in different scopes?
Thanks
Is there a way to hide the value of an aggregated value in a matrix report when a row is hidded?
Something like IIF(ReportItems!TextBox1.Hidden,True,Flase)
The above gives me an error saying that Hidden is not a member of ReportItem.
I want to do is display the sum of textboxes in a group so I can have a subtotal for every group.
I tried these things:
Sum(ReportItems!txtbudget.Value).
I can't use Fields collection because the textbox value is from custom code so there are no Fields.
I searched for options on this and one option was supposed to be adding a field to the dataset. I tried this and I get "An error occured on the report server" when building the report before I even reference the field in the report.
I even wrote code to do the sum and passed in the ReportItem. I then get the error about the grouping scope.
I want the payroll sum to be the subtotal of each column. The budget values along with some other columns are from custom code that makes database calls (which was a workaround for another problem).
Object
Object Title
Budget
Current Spent
YTD Spent
4100
EMPLOYEES
$10,000.00
$11,307.45
$40,000
4105
EMPLOYEES - TEMPORARY
$2,000.00
$506.00
$7,000
4200
EMPLOYEE BENEFITS
$13,000.00
$2,354.74
$30,000
Payroll
I can add two reportitem controls, ie reportitems!begbal.value + reportitems!deposits.value, without a problem. However, when I add the 3rd reportitem control to the expression, ie + reportitems!withdrawals.value, some really funky arithmetic occurs. All of these controls I am referring to are in the same group footer.
Any help out there would be greatly appreciated.
I am having a problem viewing my footer on all pages of my report. I have created a page footer that reads
="The " & ReportItems("textbox213").Value
I am getting the value on the first page only and then only getting "The" on the rest.
My "PrintOnFirstPage" and "PrintOnLastPage" are both marked True in the Page Footer properties. I am completely confused. This is not the only textbox in my footer I have two others both which print on all pages, but neither of them use the ReportItems.
Can anyone help on this?
Thanks....Cin
I've added a hidden field to my report so I can show the value in the page header using ReportItems. However it only works for the first page - the value is blank on subsequent pages. Does the hidden field need to appear on all pages of the report? Would I need to make it a hidden field in a repeated list or table?
View 8 Replies View RelatedI am trying to create a report which uses a table. I have typed manually each cell.
In the subtotal lines, on rows, I have used ReportItems expression. On rows it is working. However, on column, the similar ReportItems expression, instead of adding the values, it is concatenating.
Could you please help?
Regards,
Ajit.
Is there a way to make some elements on a report appear only when printed/exported ?
I recall this is possible in MS Access forms/reports, but am unable to find it in RS.
I'm thinking of Disclaimers, Company Logo etc...
I followed the instructions and the textbox named Color did indeed display alternate colors on the odd rows.
However, when I tried to propogate the color to the whole row using the expression =ReportItems!color.Value for the value of the backgroundcolor property, it was ignored.
So I tried some custom code:
Public Function GetColor()
Dim retValue as String
retValue = Me.ReportItems!Color.Value
return retValue
End Function
The syntax parser didn't like ReportItems either.
I first tried it without the Me object and I got a message about requiring an object so I tried Me.
Has anyone got another idea?
Thanks,
IanO
Hi,
May I know how can I make a simple calculation in reporting services using below formula:-
Column
B
C
D
E
Row
Group
January
February
Amt
Calc
Amt
Calc
3
a
100
=B3/B3
50
=D3/D3
4
b
200
=B4/B3
10
=D4/D3
5
c
100
=B5/B3
30
=D5/D3
6
d
150
=B6/B3
80
=D6/D3
I have build above table in reporting services. Row a, b, c, d are all belong to the same reportitems. However, I need to make a division using B3 as a based, where group = a.
I tried to make an expression with logic but it doesn't work:
Calc = reportitems!Amt.value / reportitems!Amt.value where reportitems!Group.Value='a'
Please help!! Thanks in advance!!
Hi,
Here is my problem,
I want to sum a textbox in my table group using =Sum(Reportitems!txt_erreur_cmt.Value,"table1_Group3")
but i always the same error as :
Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope
But my sum is the table group footer.
I have no ideas how do that sum.
Does anyone can help me ?
Best regards
I have a sum on a reportitems cell in my header:
=Sum(ReportItems!textbox1.Value)
When I run the report, it looks excellent. My issue is when I export it. When I export to Excel, it looks just like it did.
When I export to PDF, it gives me a total per page, not for the report.
Does ReportItem behave differently when rendered between excel and PDF? Or is it because I am putting a SUM on a ReportItems cell?
Hi,
I'm trying to get a data value to appear in the report footer on each page of my report. Using the technique described in various text books etc. I have placed a hidden text box in the report body, and the footer references this text box value.
The report is 4 pages long when I print preview it. The hidden field was initially placed near the top of the report body, so it is there on page 1 in print preview and the footer works on page 1. Pages 2,3,4 (where the hidden field ain't) just gets #Error in the footer.
If I simply move the hidden field further down in the report body so that now its on page 2 in print preview, then guess what - the footer now works on page 2 but errors everywhere else!
Why are ReportItems not known across the whole report? This is maddening. Does anyone know how to make a simple hidden text box value, that is referenced by the page footer, work so that every instance of the page footer shows the correct value?
thankyou
rob
A report I maintain has an extensive footer that appears on each page, populated with information I've stashed into invisible cells in the table's header. This works great, except in rare circumstances where the report includes a page that doesn't display the table at all--in which case the report errors when it attempts to print ("Object reference not set to an instance of an object").
Due to the requirements of the report, I cannot guarantee that the table will appear on every page, every time. Is there a way I can safely refer to the reportItems collection, in case of Nulls? I'll be okay with blank values in the footer in the cases where the page has no reportItems to work with, but I can't have the report blow up when printing.
Thanks in advance,
Jeff Lautenschlager
Hi,
I have two RDL files, one is main.rdl, the other one is sub.rdl.
In the body of main.rdl, I threw in a subreport that links to sub.rdl. Follow by the subreport is a table, in which has a textbox called mytitle. In the page footer, I added one text box that references to mytitle by using ReportItems!mytitle.Value.
When this report rendered in HTML or PDF format, it worked fine. However, when exporting to excel format, it failed. I figured it is because there isn't a ReportItem in the subreport called mytitle. I tried adding a dummy textbox into the subreport and called it mytitle, but again, no luck.
Did anyone ever encounter the same problem? Is there a work around way?
Thanks,
Hi,
Im currently writing a report in SSRS which requires to take data in the fields, manipulate and perform functions on it then display it within its own textbox. For example the field Cost is manipulated so that a column will show the cost depreciated after 5 years.
Cost Final Cost
500 250
1000 634
700 500
Footer: Totals 1384
My problem is that within each group (as the data is grouped by its type) I need to have a sum of the Final Cost data. As this is NOT a field I cannot use =Sum(Fields!FinalCost.Value, "group_1") but rather I need to use =Sum(ReportItems!FinalCost.Value, "group_1"). I know that SSRS does not allow this, but after trying to find an answer going extensively through google and many forums, I am not able to find a solution on how to sum up the Final Cost column.
If anyone has any ideas on how to resolve this issue I will be greatly thankful,
Cheers,
Ben
Hi
I need to access value of perticular row that is populated in table component from a textbox outside table.
Is there any way or option to get the all columns of dataset added to table when we add a table in data region. It will take lot of time to add one by one and also there are chances to add one column ore than once.
View 7 Replies View RelatedWhat is the syntax for adding a column where you are adding a year to a date in a date format? For example adding a column displaying a year after the participation date in date format?
View 1 Replies View Relatedhey i have a very simple form here: www.syscpupower.com
I would like to have the information from the form saved to a sql db with a time stamp.
here is the code i have for the page below:"C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
"-//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" >
"server">
"form1" runat="server">
"z-index: 108; left: 0px; position: absolute; top: 189px">
"z-index: 109; left: 204px; width: 411px; position: absolute; top: 18px;
height: 160px">
"3" rowspan="3" style="text-align: center"> Please accept to view your detailed trip information.
"Button1" runat="server" OnClick="Button1_Click" Style="z-index: 102;
left: 322px; position: absolute; top: 261px" Text="Accept" Width="60px">
"Button2" runat="server" OnClick="Button2_Click" Style="z-index: 103;
left: 392px; position: absolute; top: 261px" Text="Decline" Width="64px">
"Label1" runat="server" Style="z-index: 104; left: 254px; position: absolute;
top: 198px" Text="Please Enter Your First and Last Name!" Width="273px">
"TextBox1" runat="server" Style="z-index: 105; left: 278px; position: absolute;
top: 229px" Width="216px">
"RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="FirstName LastName" Font-Size="12px" Style="z-index: 106; left: 500px;
position: absolute; top: 229px">*
"ValidationSummary1" runat="server" Style="z-index: 110;
left: 263px; position: absolute; top: 300px" Width="284px">
Hello
A
B
C
D
1
230
40
190
190
2
470
194
276
466
3
376
328
48
514
4
558
340
218
732
5
447
483
-36
696
6
218
357
-139
557
7
395
414
-19
538
8
264
375
-111
427
9
214
285
-71
356
10
218
251
-33
323
In the above table I am looking to replicate column D in sql, columns A,B and C are already generated by the sql.
D is currently done in Excel using =D1 + C2 which is in spot D2.
Can this be done in sql? Does anyone have an example. I am looking to do it in a select query if possible.
Thanks
I have a details view with several parameters set up in my asp.net 2.0 code, I want to add a parameter before the sql parameter is executed. I need to use the find control of the details view because I am using items/edit item templates in my details view control. I tried this(see below) as well as the detailsview item command event args to no avail. It doesn't see the other parameters that have already been declared in my asp.net code. I don't want to have to declare all my varibles that are already in my asp.net code. I just want to add another parameter. Sub InsertNew(ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs) _ Handles dvEvents.ItemInserting Dim dvr As DetailsViewRow For Each dvr In dvEvents.Rows Dim CatIDup As Integer = CType(dvr.FindControl("ddlCat"), DropDownList).SelectedValue sdsevents.InsertParameters.Add("evCatID", CatIDup)sdsevents.Insert()
View 4 Replies View RelatedLooking for any help someone can offer on adding an image to SQL.Working on what will hopefully be quite a big site and the user will be asked for some details, one of which will be an image (jpg, gif or bmp).Rather than add the image to a folder on the server, a folder which could end up being quite large, I was hoping someone could give me some help, suggestions or even point me towards a tutorial on how to store the image in an SQL database.Any helps appreciated, thanks :)
View 2 Replies View RelatedHi Everyone,
I have a page with a textbox and a dropdown list. The user will enter a company name in the text box and select a number from 1 - 20 (number of delegates for that company) in the dropdown list.
I've got the text box and dropdown writing to tblCompany but I would also like it to write to tblUsers at the same time. The reason for this is that i need it to set up the number of users that have been selected in the dropdown list.
Here is the codebehind file:Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class cms_Management_Company_NewCompany
Inherits System.Web.UI.Page
Dim companyName As String
Dim companyActive As Boolean
Dim companyArchived As Boolean
Dim companyDelegates As Integer
Dim userForeName As String
Dim userSurname As String
Dim userEmail As String
Dim userUsername As String
Dim userPassword As String
Dim userActive As Boolean
Dim userTypeID As Integer
Dim companyID As Integer
Dim i As Integer
Dim NoLoops As Integer
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSave.Click
Dim conString As String = WebConfigurationManager.ConnectionStrings("General").ConnectionString
Dim con As New SqlConnection(conString)
Dim cmd As New SqlCommand("INSERT INTO tblCompany (CompanyName, CompanyActive, CompanyArchived, CompanyDelegates) VALUES (@CompanyName, @CompanyActive, @CompanyArchived, @CompanyDelegates)", con)
cmd.Parameters.AddWithValue("@CompanyName", companyName)
cmd.Parameters.Item("@CompanyName").Value = txtCompanyName.Text
cmd.Parameters.AddWithValue("@CompanyDelegates", companyDelegates)
cmd.Parameters.Item("@CompanyDelegates").Value = lstDel.SelectedValue
cmd.Parameters.AddWithValue("@CompanyActive", companyActive)
cmd.Parameters.Item("@CompanyActive").Value = True
cmd.Parameters.AddWithValue("@CompanyArchived", companyArchived)
cmd.Parameters.Item("@CompanyArchived").Value = False
Using con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
Dim con2 As New SqlConnection(conString)
Dim cmd2 As New SqlCommand("INSERT INTO tblUsers (UserForeName, UserSurname, UserEmail, UserUsername, UserPassword, UserActive, UserTypeID, CompanyID) VALUES (@UserForeName, @UserSurname, @UserEmail, @UserUsername, @UserPassword, @UserActive, @UserTypeID, @CompanyID)", con2)
cmd2.Parameters.AddWithValue("@UserForeName", userForeName)
cmd2.Parameters.Item("@UserForeName").Value = "First Name - Delegate 1"
cmd2.Parameters.AddWithValue("@UserSurname", userSurname)
cmd2.Parameters.Item("@UserSurname").Value = "Surname - Delegate 1"
cmd2.Parameters.AddWithValue("@UserEmail", userEmail)
cmd2.Parameters.Item("@UserEmail").Value = "Email Address - Delegate 1"
cmd2.Parameters.AddWithValue("@UserUsername", userUsername)
cmd2.Parameters.Item("@UserUsername").Value = "Username - Delegate 1"
cmd2.Parameters.AddWithValue("@UserPassword", userPassword)
cmd2.Parameters.Item("@UserPassword").Value = "Password - Delegate 1"
cmd2.Parameters.AddWithValue("@UserActive", userActive)
cmd2.Parameters.Item("@UserActive").Value = True
cmd2.Parameters.AddWithValue("@UserTypeID", userTypeID)
cmd2.Parameters.Item("@UserTypeID").Value = 2
cmd2.Parameters.AddWithValue("@UserTypeID", userTypeID)
cmd2.Parameters.Item("@UserTypeID").Value = 1
Using con2
con2.Open()
For i = 1 To NoLoops
cmd2.ExecuteNonQuery()
Next i
con2.Close()
End Using
Response.Redirect("~/cms/Management/Company/Company.aspx")
End Sub
End ClassThe other thing I am not sure of is getting the ID of the new company and assiging it to the delegates in tblUsers (to associate them with the new company)I hope this makes sense.Thank you very much guys.Scott.
I am trying to insert a value numeric + 1 in to db table but i get error when i do this
this is the code
Const SQL As String = "INSERT INTO [PageHits] ([DefaultPage]) VALUES (@defaultP)"Dim myCommand As New Data.SqlClient.SqlCommand(SQL, myConnection)myCommand.Parameters.AddWithValue("@DefaultP" + "1", DefaultP.Text.Trim())
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
The Error:
Must declare the variable '@defaultP'.
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: Must declare the variable '@defaultP'.
i want to add vales in a query
this is my scenario (how can i add the price column values and display as one record) ex. 222 17
table = table1
tep1 price (column)
222 5
222 2
222 10
Hi all,
I have a database setup with a few rows and i would like to allow a user to create a new row of data. After some googling, I've deduced that I need to somehow use an onclick command to perform an insert command. here is my code as of right now:
protected void ItemAdd_Click(object sender, EventArgs e)
{int newnum = 4;int POnum = newnum ++;
string Item = textbox3.Text.ToString();
string Quantity = textbox4.ToString();string Part = textbox5.ToString();
string Description = textbox6.Text.ToString();string Price = textbox7.Text.ToString();string UOM = textbox8.Text.ToString();
SqlDataSource2.InsertParameters.Clear();
SqlDataSource2.InsertParameters.Add("@Item", Item);SqlDataSource2.InsertParameters.Add("@Quantity", Quantity);
SqlDataSource2.InsertParameters.Add("@Part", Part);SqlDataSource2.InsertParameters.Add("@Description", Description);
SqlDataSource2.InsertParameters.Add("@Price", Price);SqlDataSource2.InsertParameters.Add("@UOM", UOM);
SqlDataSource1.InsertCommand = "insert into ItemMaster "+"values (12, @Item, @Quantity, @Part, @Description, @Price, @UOM)";
SqlDataSource2.Insert();
}
here's the aspx:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="createpo.aspx.cs" Inherits="Subpgs_Purchasing_createpo" Title="Create A PO" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 600px; position: relative; top: 30px; height: 253px" cellpadding="10px">
<tr>
<td style="width: 180px; text-align: left;" rowspan="2">
Select Vendor<br />- or -<br /><asp:LinkButton ID="Linkbutton1" runat="server" OnClick="Linkbutton1_Click">Create Vendor</asp:LinkButton></td>
<td style="width: 100px" rowspan="2">
<asp:ListBox ID="ListBox2" runat="server" DataSourceID="SqlDataSource1" DataTextField="Name"
DataValueField="ID" OnSelectedIndexChanged="ListBox2_SelectedIndexChanged"></asp:ListBox><asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Vendor_info]"></asp:SqlDataSource>
</td>
<td style="width: 180px; text-align: left;">
Job/Req.S.O. No.</td>
<td style="width: 100px">
<asp:TextBox ID="Job" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 180px; text-align: left;">
Terms</td>
<td style="width: 100px">
<asp:TextBox ID="Terms" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 180px; text-align: left;">
F.O.B.</td>
<td style="width: 100px">
<asp:TextBox ID="FOB" runat="server"></asp:TextBox></td>
<td style="width: 180px; text-align: left;">
Ship To:<br />
Address:<br />
City / State / Zip:</td>
<td style="width: 100px">
<asp:TextBox ID="Ship1" runat="server"></asp:TextBox>
<asp:TextBox ID="Ship2" runat="server"></asp:TextBox>
<asp:TextBox ID="Ship3" runat="server"></asp:TextBox></td>
</tr>
</table>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Purchase_Orders.mdf;Integrated Security=True;User Instance=True;Context Connection=False"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [Item], [Quantity], [Part], [Description], [Price], [UOM], [Ammount], [PONumber] FROM [ItemMaster]" DeleteCommand="DELETE FROM [ItemMaster] WHERE [PONumber] = @PONumber" InsertCommand="INSERT INTO [ItemMaster] ([Item], [Quantity], [Part], [Description], [Price], [UOM], [Ammount], [PONumber]) VALUES (@Item, @Quantity, @Part, @Description, @Price, @UOM, @Ammount, @PONumber)" UpdateCommand="UPDATE [ItemMaster] SET [Item] = @Item, [Quantity] = @Quantity, [Part] = @Part, [Description] = @Description, [Price] = @Price, [UOM] = @UOM, [Ammount] = @Ammount WHERE [PONumber] = @PONumber">
<DeleteParameters>
<asp:Parameter Name="PONumber" Type="Decimal" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Item" Type="String" />
<asp:Parameter Name="Quantity" Type="Decimal" />
<asp:Parameter Name="Part" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="UOM" Type="String" />
<asp:Parameter Name="Ammount" Type="Decimal" />
<asp:Parameter Name="PONumber" Type="Decimal" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Item" Type="String" />
<asp:Parameter Name="Quantity" Type="Decimal" />
<asp:Parameter Name="Part" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="UOM" Type="String" />
<asp:Parameter Name="Ammount" Type="Decimal" />
<asp:Parameter Name="PONumber" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
<br />
<table>
<tr>
<td>Item #</td>
<td><asp:TextBox ID="textbox3" runat=server></asp:TextBox></td>
<td>Quantity</td>
<td><asp:TextBox ID="textbox4" runat=server></asp:TextBox></td>
<td>Part Number</td><td><asp:TextBox ID="textbox5" runat=server></asp:TextBox></td>
</tr>
<tr>
<td>Description</td>
<td><asp:TextBox ID="textbox6" runat=server></asp:TextBox></td>
<td>Unit Price</td>
<td><asp:TextBox ID="textbox7" runat=server></asp:TextBox></td>
<td>Unit of Measure</td>
<td><asp:TextBox ID="textbox8" runat=server></asp:TextBox></td>
</tr>
<tr>
<td colspan="6" align="center"><asp:Button ID="ItemAdd" runat=server text="Add Item" OnClick="ItemAdd_Click" /></td>
</tr>
</table>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PONumber"
DataSourceID="SqlDataSource2">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Item" HeaderText="Item" SortExpression="Item" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Part" HeaderText="Part" SortExpression="Part" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="UOM" HeaderText="UOM" SortExpression="UOM" />
<asp:BoundField DataField="Ammount" HeaderText="Ammount" SortExpression="Ammount" />
<asp:BoundField DataField="PONumber" HeaderText="PONumber" ReadOnly="True" SortExpression="PONumber"
Visible="False" />
</Columns>
</asp:GridView>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit Data" OnClick="Button1_Click" /> <br />
<br />
<asp:Label ID="Label1" runat="server" Text="Please Verify Information below!" Visible="False"></asp:Label><br />
<br />
<table align="left">
<tr>
<td style="width: 200px; text-align: left;">
<asp:Label ID="Label4" runat="server" Text="Job/REQ.S.O. No." Visible="false"></asp:Label></td>
<td style="width: 200px; text-align: left;">
<asp:Label ID="Label5" runat="server"></asp:Label></td>
</tr>
<tr>
<td style="width: 200px; text-align: left;">
<asp:Label ID="Label7" runat="server" Text="Terms" Visible="false"></asp:Label></td>
<td style="width: 200px; text-align: left;">
<asp:Label ID="Label8" runat="server"></asp:Label></td>
</tr>
<tr>
<td style="width: 200px; text-align: left;">
<asp:Label ID="Label10" runat="server" Text="F.O.B." Visible="false"></asp:Label></td>
<td style="width: 200px; text-align: left;">
<asp:Label ID="Label11" runat="server"></asp:Label></td>
</tr>
</table>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
Height="50px" Visible="False" Width="260px" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataKeyNames="ID" ForeColor="Black">
<FooterStyle BackColor="#CCCCCC" />
<EditRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Street" HeaderText="Street" SortExpression="Street" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
<asp:BoundField DataField="Telephone Number" HeaderText="Telephone Number" SortExpression="Telephone Number" />
<asp:BoundField DataField="Contact Information" HeaderText="Contact Information"
SortExpression="Contact Information" />
<asp:BoundField DataField="E-mail address" HeaderText="E-mail address" SortExpression="E-mail address" />
<asp:BoundField DataField="Fax Number" HeaderText="Fax Number" SortExpression="Fax Number" />
<asp:BoundField DataField="Comments" HeaderText="Comments" SortExpression="Comments" />
</Fields>
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:DetailsView>
<br />
<br />
<br />
<asp:Button ID="Button2" runat="server" Text="E-Mail PO" Visible="False" OnClick="Button2_Click" />
</asp:Content>
whenever I run this, I receive the following error and am not sure how to correct it:
System.Data.SqlClient.SqlException: Must declare the scalar variable "@Item".
If someone could please explain to me the process here of what is going ion it would be greatly appreciated. My understanding is the @item is just a variable if you will so i'm not sure why its stating i need to declare it.
Thank you all!
Hi Guys,
I know this is a little off the subject of ASP.net but I am using some code behind in C#. I am a real novice at this and so it may appear to be a simple question but Im trying to add a number to the database from a textbox but it is having issues as the Storenum is an int and it wants a string. Can anyone help? I know I need to write .tostring somewhere but can't work out where. My code is below.
Thanks in advance. =)
public partial class _addstore : System.Web.UI.Page
{protected string Location;
protected string Telephone;protected string Prefix;
protected int StoreNum;protected string myConnectionString;protected void Page_Load(object sender, EventArgs e)
{
Location = "default";Telephone = "default";
Prefix = "default";StoreNum = "0";myConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\inetpub\wwwroot\HOF\App_Data\HOF.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;";
}protected void Button1_Click(object sender, EventArgs e)
{int sa;
SqlConnection myConnection = new SqlConnection(myConnectionString);
try
{
Location = TextBox2.Text;
Telephone = TextBox3.Text;
Prefix = TextBox4.Text;
StoreNum = TextBox5.Text;SqlCommand myCommand = new SqlCommand("INSERT INTO StoreInfo (StoreID, Location, Telephone, Prefix) Values (" + StoreNum + ", '" + Location + "', '" + Telephone + "', '" + Prefix + "')", myConnection);SqlDataAdapter myDataAdapter = new SqlDataAdapter(myCommand);
myConnection.Open();
sa = myCommand.ExecuteNonQuery();
myConnection.Close();
}catch (Exception ex)
{
TextBox2.Text = ex.Message;
myConnection.Close();
}
}
}
tell me how to add foreign keys in sql 2005 express
View 3 Replies View RelatedI am trying to create a sql database that will have a table with the following parameters. ID, Name, Picture. So i create the table and set the ID to an int the Name to an nvchar and the Picture to an image. My question is now how to i add a picture to this database. When i rightclick on the table and click show table data and attempt to add an image all i can type in is text. Thank you for your help
View 8 Replies View RelatedHi,I have an application up and running. I need to add a new column to one of the tables which is currently being used - would adding a new column change or cause errors in the current application? e.g. if the table is being accessed by selecting * from table, will adding a new column cause an error? If there is any circumstance where an error would be caused by adding a new column, I will have to create an entirely new table. If I have to do this - how do I get a column in the new table to have the same values as a column in the old table? Can I create a computed column where column=oldcolumn? Thanks,Jon
View 5 Replies View RelatedWhen using the Xp_sendmail stored procedure from MS SQL 2000, I cannot use LF or CR of both otr VBnewLine in my messages.
For example
<code>
Trim(lblEmployee.Text) & " has requested a holiday. From " & CalendarPopupStartDate.SelectedDate & " till " & CalendarPopupStartDate.SelectedDate _
& "." & CARRIAGE RETURN WANTED &lblRequestedDays.Text & txtComments.Text
<code>
where you find the CARRIAGE RETURN WANTED, I want to begin a new line. My email is not formated asked :(
any help?
Greetz,
Geoff
I'm in trouble. I have a table with some fields, one of them is an amount of money.
One field indicates whether the amount is negetive or positive. This fields has only two possible values, 'N' and 'R'. 'N' means the amount is negative and 'R' means the amount is positive.
The problem I have is that I have to sum these amounts to give a total for each customer and report them as
customer1 total amount1
customer2 total amount2
I don't know how to make a query to bring these results. I know that sum would bring me the total amount for each customer but I don't know how to specify which fields are supposed to be negative so that it subtracts them instead of adding them.
By the way I'm not allowed to change the structure of the table.
Could you help me try to create this query?