Hello
i am use sqldatasource in asp.net page and need to use Advance SQL Generation Option for update,delete,edit table date but Advance SQL Generation Option is Disable by default.......how to enable this option plzzzz help me............
Hello
i am use sqldatasource in asp.net page and need to use Advance SQL Generation Option for update,delete,edit table date but Advance SQL Generation Option is Disable by default.......how to enable this option plzzzz help me............
I am working with an ASP.net 4.0 page with SQL Server 2005. I am writing a query that gets data about paramedics and how much time they spend in certain status such as "on scene", "at hospital", etc. I then compare the individual paramedic to the organization as a whole to see if he is over the average or below. My time frame is for a whole year of data and I keep getting the error:
"Arithmetic overflow error converting expression to data type int"
This query runs just fine in SQL Server Management Studio and returns a result within a few seconds. However with my ASP.net page I receive the error mentioned above.
There is a lot of data in these tables so I use CAST AS BIGINT when I sum up the seconds in status. This does not seem to help. Once again, this query runs fine and returns a result in SSMS.
Can anyone see why this error continues to happen? Code for the whole page shown below.
<%@ Page Title="" Language="C#" MasterPageFile="~/LCEMS.master" AutoEventWireup="true" CodeFile="PersonalPerformanceMetrics2.aspx.cs" Inherits="EMTParamedic_StrategicMetrics_PersonalPerformanceMetrics2" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"><asp:SqlDataSource ID="qryPersonal" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [POF_OfficerName], [POF_Officer_PK] FROM [POfficer] ORDER BY [POF_OfficerName]"></asp:SqlDataSource><asp:SqlDataSource ID="qryPerformance" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="With paramedicData AS ( SELECT M_kIncident , CASE WHEN M_Code IN ('USDP', 'USDR') THEN 'Dispatch' WHEN M_Code IN ('USER') THEN 'EnRoute' WHEN M_Code IN ('USOL', 'USEC') THEN 'OffLoading' WHEN M_Code IN ('USAV') THEN 'Available' WHEN M_Code IN ('USAR', 'USIH', 'UST1', 'USCR', 'USSA', 'USST', 'USS7') THEN 'OnScene' WHEN M_Code IN ('USTA', 'USEO') THEN 'TransportArrive' ELSE 'NA' END AS [Disposition] , SUM(CAST(M_SecondsAtStatus AS BIGINT)) AS [TimeInStatus] FROM MManpower LEFT OUTER JOIN POfficer ON (M_kOfficer1 = POF_Officer_PK) OR (M_kOfficer2 = POF_Officer_PK) WHERE POF_Officer_PK = @OfficerPK AND M_Code IN ('USDP', 'USDR', 'USER', 'USOL', 'USEC', 'USAV', 'USAR', 'USIH', 'UST1', 'USCR', 'USSA', 'USST', 'USS7', 'USTA', 'USEO') AND M_tTime BETWEEN @cal1 AND @cal2 GROUP BY M_kIncident , CASE WHEN M_Code IN ('USDP', 'USDR') THEN 'Dispatch' WHEN M_Code IN ('USER') THEN 'EnRoute' WHEN M_Code IN ('USOL', 'USEC') THEN 'OffLoading' WHEN M_Code IN ('USAV') THEN 'Available' WHEN M_Code IN ('USAR', 'USIH', 'UST1', 'USCR', 'USSA', 'USST', 'USS7') THEN 'OnScene' WHEN M_Code IN ('USTA', 'USEO') THEN 'TransportArrive' ELSE 'NA' END ) , everyoneElse AS ( SELECT M_kIncident , CASE WHEN M_Code IN ('USDP', 'USDR') THEN 'Dispatch' WHEN M_Code IN ('USER') THEN 'EnRoute' WHEN M_Code IN ('USOL', 'USEC') THEN 'OffLoading' WHEN M_Code IN ('USAV') THEN 'Available' WHEN M_Code IN ('USAR', 'USIH', 'UST1', 'USCR', 'USSA', 'USST', 'USS7') THEN 'OnScene' WHEN M_Code IN ('USTA', 'USEO') THEN 'TransportArrive' ELSE 'NA' END AS [Disposition] , SUM(CAST(M_SecondsAtStatus AS BIGINT)) AS [TimeInStatus] FROM MManpower LEFT OUTER JOIN PUnit ON M_kUnit = PUN_Unit_PK WHERE M_Code IN ('USDP', 'USDR', 'USER', 'USOL', 'USEC', 'USAV', 'USAR', 'USIH', 'UST1', 'USCR', 'USSA', 'USST', 'USS7', 'USTA', 'USEO') AND PUN_UnitAgency = 'LC' AND M_tTime BETWEEN @cal1 AND @cal2 GROUP BY M_kIncident , CASE WHEN M_Code IN ('USDP', 'USDR') THEN 'Dispatch' WHEN M_Code IN ('USER') THEN 'EnRoute' WHEN M_Code IN ('USOL', 'USEC') THEN 'OffLoading' WHEN M_Code IN ('USAV') THEN 'Available' WHEN M_Code IN ('USAR', 'USIH', 'UST1', 'USCR', 'USSA', 'USST', 'USS7') THEN 'OnScene' WHEN M_Code IN ('USTA', 'USEO') THEN 'TransportArrive' ELSE 'NA' END ) , paramedicAverages AS ( SELECT Disposition , COUNT(M_kIncident) AS [paramedicVolume] , AVG(CAST(TimeInStatus AS BIGINT)) AS [paramedicAverage] FROM paramedicData GROUP BY Disposition ) , everyoneAverages AS ( SELECT Disposition , COUNT(M_kIncident) AS [everyoneVolume] , AVG(CAST(TimeInStatus AS BIGINT)) AS [everyoneAverage] FROM everyoneElse GROUP BY Disposition ) SELECT paramedicAverages.Disposition , paramedicVolume /*, CONVERT(VARCHAR(20), DATEADD(ms, paramedicAverage * 1000, 0), 108) AS [paramedicAverage]*/ , ParamedicAverage , everyoneVolume /*, CONVERT(VARCHAR(20), DATEADD(ms, everyoneAverage * 1000, 0), 108) AS [everyoneAverage]*/ , EveryoneAverage FROM paramedicAverages INNER JOIN everyoneAverages ON paramedicAverages.Disposition = everyoneAverages.Disposition " OnSelecting="qryPerformance_Selecting"><SelectParameters><asp:ControlParameter ControlID="ddlMedic" Name="OfficerPK" PropertyName="SelectedValue" /><asp:ControlParameter ControlID="Calendar1" Name="cal1" PropertyName="SelectedDate" /><asp:ControlParameter ControlID="Calendar2" Name="cal2" PropertyName="SelectedDate" /></SelectParameters></asp:SqlDataSource><asp:DropDownList ID="ddlMedic" runat="server" DataSourceID="qryPersonal" DataTextField="POF_OfficerName" DataValueField="POF_Officer_PK"></asp:DropDownList><asp:Calendar ID="Calendar1" runat="server"></asp:Calendar><asp:Calendar ID="Calendar2" runat="server"></asp:Calendar><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="qryPerformance"><Columns><asp:BoundField DataField="Disposition" HeaderText="Disposition" ReadOnly="True" SortExpression="Disposition" /><asp:BoundField DataField="paramedicVolume" HeaderText="paramedicVolume" ReadOnly="True" SortExpression="paramedicVolume" /><asp:BoundField DataField="ParamedicAverage" HeaderText="ParamedicAverage" ReadOnly="True" SortExpression="ParamedicAverage" /><asp:BoundField DataField="everyoneVolume" HeaderText="everyoneVolume" ReadOnly="True" SortExpression="everyoneVolume" /><asp:BoundField DataField="EveryoneAverage" HeaderText="EveryoneAverage" ReadOnly="True" SortExpression="EveryoneAverage" /></Columns></asp:GridView></asp:Content>
Hi I am follow the Music Store Tutorial and have got a little stuck I am using Visual Studio 2013 and got as far as part 4.
I come across these errors:
Error 1 The name 'RegisterGlobalFilters' does not exist in the current context
Error 2 The name 'RegisterRoutes' does not exist in the current context
{ System.Data.Entity.Database.SetInitializer( new MvcMusicStore.Models.SampleData()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }
I have tried follow Terry Guo answer at http://forums.asp.net/t/1966851.aspx?Music+Store+Tutorial+Local+Database+Connection+Error
But I still get an error for FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
Error 1 The name 'FilterConfig' does not exist in the current context
{ System.Data.Entity.Database.SetInitializer( new MvcMusicStore.Models.SampleData()); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); }
I really don't know what I've missed any help would be greatly appreciated
Thanks
Hi guys,
I need apply custom paging on a gridview by passing page index and page size. I have a dataset contain all records which are populating from multiple table by using a join query. and based on some condition i filtered records into dataview and in my application dataview used as datasources of a gridview and gridview has allow paging to true.
how would i apply custom paging on this gridview, i mean i want to pass page index and page size on dataview and it will return me a filtered dataview which can be used as data sources for next page index.
Thanks in advances.
Hello...
I have a legacy application with Typed Dataset.
Is possible to convert XSD file in vb.net code ?
And then delete XSD file ?
Thanks
Hi guys
Could anyone please help me out, I am trying to display the sum of a column in an sql table in a Text Box, I am really stuck on this and appreciate any help please
So I have 20 columns and I want to display the sum of the each column (RB1 to RB20) in textboxes (TextBox1 to TextBox20)
Could anyone please help on this?
Should this be done as a stored procedure or within the code behin and how?
Kind regards
hi. We used to fetch data from one server (SQL Server 2008). Now, we have changed to New Server. After changing to new server, we are unable to fetch or connect with sql server. No Error or Warning Messages after execution. pls mention the reason and solution
Hi Guys, I am trying to insert data in an SQL table by executing an Insert Query.
The problem is that I need to get the column name from a cell in the selected gridview Row.
Here's the snippet:
SqlCommand cmd30 = new SqlCommand("insert into mytable ( '"+GridView7.SelectedRow.Cells[0].Text+"' , r_id) values ('"+ GridView7.SelectedRow.Cells[1].Text +"', '"+TextBox1.Text+"')",con30);
cmd30.ExecuteNonQuery();
**r_id is not a Primary Key.
The Error is get is:
Also is it possible to get the column name of the table from a specific cell of the selected Gridview row?
That seems to be the problem.
Any Help will be appreciated.
Thanks,
Shaleen
Hello,
I want to copy the existing sql table into new one using the number of the version. I have this code, but it doesn't add the number as a parameter which was entered by the code. It adds only @i to the table name. Can anybody help me please how to add it as the parameter passed from the asp page?
CREATE PROCEDURE Saveas
@i nvarchar
AS
Select *
Into TrafInc1_version_@i
From TrafInc1
Thanks
Hi,
I've created a texbox in asp.net and used tiny_mce java changed it to richtextBox and now I want to save it to sql database and retrieve this saved information to asp page
how to save it and retrieve info And which data type I have to use in sql
plz help, THANKS
Hi,
I create Rich text Box by using Tiny_MCE I saved info inside sql by linq and now I want to retrieve saved info in That Rich Text Box
how to do that?
Plz help me Thanks.
Greetings Experts,
I have this:
<asp:TemplateField HeaderText=""><ItemTemplate><asp:TextBox ID="trainingId" runat="server" Text='<%# Bind("trainingId") %>' style="display:none" ></asp:TextBox></ItemTemplate></asp:TemplateField>
Then this query:
SelectCommand="select tl.trainingid,l.locationid,c.CourseId,i.instructorId,CourseName,i.instructorname, dbo.fnFormatDate(t.trainingDates, 'MON/DD/YYYY') trainingDates,t.trainingTime,CourseDescription from tblCourses c inner join tblLocations l on c.locationid = l.locationid inner join tblTrainingDates t on c.dateId = t.dateId inner join tblCourseInstructor ci on c.courseid=ci.courseid inner join tblInstructors i on ci.instructorid = i.instructorId inner join tblTrainings tl on ci.courseId = tl.courseId and YEAR(t.trainingDates) = YEAR(getDate()) and tl.trainingId = @trainingId" FilterExpression="LocationId = '{0}'" >
Finally, the parameters declaration section:
<SelectParameters>
<asp:Parameter Type="Int32" Name="trainingId"/>
</SelectParameters>
When I run the code, I get no records but no records get displayed.
If however, I run the code in SQL Server Management Studio, and replace @TrainingId with hardcoded value, I get results.
Any ideas how to make it work?
The idea of what we are trying to do is you select a location and results based on that location are displayed.
It is not working for me.
Your assistance is greatly appreciated.
Hi all. I'm using a SqlDataSource component on a ASP.NET page. If I execute a sql query directly on database, results are available in 1 second or less.
But same query, executed with SqlDataSource in the page returns nothing, as if it went in timeout. Database has a very large omount of data, but my query result 117 records only.
Any suggestions?
Hi I need a help on how to go about this
I am using two tables DailyCalibration and Tank
This my query here
SELECT DistinctDailyCalibration.Site_code,Tank.Item,DailyCalibration.period,Max(DailyCalibration.date_dt) AS LastUpdated,Sum(DailyCalibration.quantity) AS QTY FROM DailyCalibrationINNER JOINTank ON DailyCalibration.tank =Tank.TankGroup BY DailyCalibration.Site_code,Tank.Item,DailyCalibration.period
This is My result
+-------+----------+---------+-------------+---------------+Site_code|Item|Period|LastUpdated| QTY+--------+----------+-------+-------------+---------------+100| AGO | EVENING |2013-11-20|814355.793+--------+----------+-------+-------------+---------------+100| AGO | MORNING |2013-11-07|1104501.012+----------+--------+-------+-------------+---------------+100| PMS | EVENING |2013-11-21|18000.000+----------+--------+-------+-------------+---------------+100| PMS | MORNING |2013-11-07|200000.055+----------+--------+-------+-------------+---------------+101| AGO | EVENING |2013-11-21|1067478.693+----------+--------+-------+-------------+---------------+101| AGO | MORNING |2013-11-07|1437515.483+----------+--------+-------+-------------+---------------+101| PMS | EVENING |2013-11-21|28000.000+----------+--------+-------+-------------+---------------+101| PMS | MORNING |2013-11-07|18000.505
But I want to transform it this way
+-------+-------------+---------+--------------+------------+Site_code|LastUpdated|Period| AGO | PMS +-------+-------------+---------+--------------+------------+100|2013-11-20| MORNING |1104501.012|200000.055+-------+-------------+---------+--------------+------------+100|2013-11-07| EVENING |814355.793|18000.000+-------+-------------+---------+--------------+------------+101|2013-11-20| MORNING |1437515.483|18000.505+-------+-------------+---------+--------------+------------+101|2013-11-07| EVENING |1067478.693|28000.000+-------+-------------+---------+--------------+------------+
Pls Can Someone help Me out
Thanks All.
here is my code..
ds2.Clear(); SqlDataAdapter getnewsfeeds; SqlDataAdapter friendadapter = new SqlDataAdapter("select * from " + Session["username"].ToString() + "_friends ", friendscon); friendadapter.Fill(friendsdataset); int friendrowcount = friendsdataset.Tables[0].Rows.Count; if (friendrowcount > 0) { for (int i = 0; i < friendrowcount; i++) { friendstringtable = " " + friendsdataset.Tables[0].Rows[i]["friendsusername"].ToString(); getnewsfeeds = new SqlDataAdapter("select top 5 * from " + friendstringtable + "_newsfeeds order by id desc", Newsfeedscon); getnewsfeeds.Fill(ds2, "newsfeed"); } } getnewsfeeds.Fill(ds2, "newsfeed"); ds2.Tables["newsfeed"].DefaultView.Sort = "time_date desc"; DataView dv = ds2.Tables["newsfeed"].DefaultView; dt = dv.ToTable();
Hi,
I want to retreive image from sql database without using httpContext Class,
I am troubleshooting some code written in Asp.net 1.1. Below is the code behind a web form:
Me.cmdSetLastProject = New System.Data.SqlClient.SqlCommand ... Me.cmdSetLastProject.CommandText = "dbo.[procSetLastProject]" Me.cmdSetLastProject.CommandType = System.Data.CommandType.StoredProcedure Me.cmdSetLastProject.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing)) Me.cmdSetLastProject.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UserLogin", System.Data.SqlDbType.NVarChar, 50)) Me.cmdSetLastProject.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FirmID", System.Data.SqlDbType.Int, 4)) Me.cmdSetLastProject.Parameters.Add(New System.Data.SqlClient.SqlParameter("@LastProjectID", System.Data.SqlDbType.Int, 4)) ... Protected WithEvents cmdSetLastProject As System.Data.SqlClient.SqlCommand
Here's the stored procedure for the command object: ALTER PROC [dbo].[procSetLastProject] @UserLogin nvarchar(50), @FirmID int, @LastProjectID int AS UPDATE Users SET LastProjectID = @LastProjectID WHERE UserLogin = @UserLogin AND FirmID = @FIrmID
Here's how it is used:
Private Sub ddlProjects_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlProjects.SelectedIndexChanged ' Store selected project for next time Dim cnn As SqlConnection = New SqlConnection(strConnection) cmdSetLastProject.Connection = cnn If Session("UserName") Is Nothing Then GetUserNameFromCookie() cmdSetLastProject.Parameters("@UserLogin").Value = Session("UserName") If Session("FirmID") Is Nothing Or CInt(Session("FirmID")) = 0 Then Session("FirmID") = GetFirmIDFromCookie() cmdSetLastProject.Parameters("@FirmID").Value = CInt(Session("FirmID")) cmdSetLastProject.Parameters("@LastProjectID").Value = ddlProjects.SelectedValue If Me.ddlProjects.SelectedValue <> 0 Then 'create cookie CreateProjectIDCookie(Me.ddlProjects.SelectedValue) End If cnn.Open() cmdSetLastProject.ExecuteNonQuery() cnn.Close()
Why is this line in the code behind?
Me.cmdSetLastProject.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Hi,
Ok, I'm fairly new to ASP.NET programming. I am also fairly new to these forums, so please re-direct me if I've posted this in the wrong place!
I am trying to write a web-based application in C#. I need a database on the back-end. While developing, I want everything to run on my local machine using the built-in SQL express, but when I deploy, I intend it to be an IIS / SQL server model.
I *THINK* I need to set up a database project to build the database itself. I added one to my solution file. I am assuming that this will allow me to build a deployment that both sets up the application and its database. I now cannot, however, figure out how to create the dbml file to reference it.
Despite typing everything I can think of into Google, I haven't found a how-to or a walkthrough. Can anyone either explain the process to me, or point me at a good tutorial?
Thanks!
Oh, Visual Studio 2010.
Hi,
I am doing a simple project on Visual Studio 2013 about a book library. I have a database from which I will get the information for the GridView 's.
The purpose of this page is to display the list of authors and their respective titles.
So, basically, I have a GridView which will display the author's names and IDs. I added a column to the end and edited it as a template so I could include another GridView - this one will contain the book titles for the respective author in the first GridView.
The first GridView is connected to a first ObjectDataSource which will call a function GetData() (which will return the right table to be shown on the GridView). The second GridView is connected to a second ObjectDataSource which will call a function GetTitlesByAuthor. But, this function receives an argument: the 'au_id' (author_ID).
My problem is: How can I pass the parameter 'au_id' depending on the value of the 'au_id' displayed on the first GridView rows?
This is my current code:
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" DataKeyNames="au_id" DataSourceID="ObjectDataSource1"><AlternatingRowStyle BackColor="White" /><Columns><asp:BoundField DataField="au_id" HeaderText="Author ID" ReadOnly="True" SortExpression="au_id" /><asp:BoundField DataField="au_lname" HeaderText="LastName" SortExpression="au_lname" /><asp:BoundField DataField="au_fname" HeaderText="FirstName" SortExpression="au_fname" /><asp:TemplateField HeaderText="Titles"><ItemTemplate><asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource2" ForeColor="#333333" GridLines="None" ShowHeader="False" DataKeyNames="au_id"><AlternatingRowStyle BackColor="Transparent" /><Columns><asp:TemplateField><ItemTemplate><asp:Image ID="Image1" runat="server" ImageUrl="~/Images/bullet.png" /></ItemTemplate></asp:TemplateField><asp:BoundField DataField="title" HeaderText="title" SortExpression="title" /></Columns><EditRowStyle BackColor="#7C6F57" /><FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /><RowStyle BackColor="Transparent" /><SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /><SortedAscendingCellStyle BackColor="#F8FAFA" /><SortedAscendingHeaderStyle BackColor="#246B61" /><SortedDescendingCellStyle BackColor="#D4DFE1" /><SortedDescendingHeaderStyle BackColor="#15524A" /></asp:GridView><asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetTitlesByAuthor" TypeName="MyStore.DataSet1TableAdapters.AuthorTitlesTableAdapter"><SelectParameters><asp:Parameter DefaultValue="409-56-7008" Name="author_ID" Type="String" /></SelectParameters></asp:ObjectDataSource></ItemTemplate></asp:TemplateField></Columns><EditRowStyle BackColor="#7C6F57" /><FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /><RowStyle BackColor="#E3EAEB" /><SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /><SortedAscendingCellStyle BackColor="#F8FAFA" /><SortedAscendingHeaderStyle BackColor="#246B61" /><SortedDescendingCellStyle BackColor="#D4DFE1" /><SortedDescendingHeaderStyle BackColor="#15524A" /></asp:GridView><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="MyStore.DataSet1TableAdapters.AuthorsTableAdapter"></asp:ObjectDataSource>
Would appreciate any help. This is for academic purposes.
Thanks!
Hi,
Is it more efficient to have one long sp containing several if statements or several smaller ones?
Thanks