|
Not a question. However, if it were a question regarding what can a heavy traffic website handle the answer would still be "it depends." Availability and responsiveness are dependent on many different factors including the performance of IIS and then also of the sql db and the network. Many, many, different factors.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hello,
i am novice in asp.net and i want to write an sql query that will calculate student grade and grade point base on the condition bellow.
WHEN EXAMS BETWEEN 75 AND 100 THEN 'A'
WHEN EXAMS BETWEEN 70 AND 74 THEN 'AB'
WHEN EXAMS BETWEEN 65 AND 69 THEN 'B'
WHEN EXAMS BETWEEN 60 AND 64 THEN 'BC'
WHEN EXAMS BETWEEN 55 AND 59 THEN 'C'
WHEN EXAMS BETWEEN 50 AND 54 THEN 'CD'
WHEN EXAMS BETWEEN 45 AND 49 THEN 'D'
WHEN EXAMS BETWEEN 40 AND 44 THEN 'E'
WHEN EXAMS BETWEEN 40 AND 0 THEN 'F'
please how can i do this query, than you
|
|
|
|
|
I dont see what your question has to do with ASP.Net - and you've posted it in two different places. In future pick ONE forum and post there please
|
|
|
|
|
I am using a stored procedure in entity framework its returning two columns in sql server but when i am using in entity framework its returning no column please do needful.
modified 21-Nov-15 2:16am.
|
|
|
|
|
Er. Aamir Khan KCNIT Banda wrote: please do needful. What needful?
|
|
|
|
|
Entity framework returns no columns but in sql its returning.?
USE [UPOR_DE_MAIN]
GO
/****** Object: StoredProcedure [dbo].[usp_s_UDMFieldChaltaNos] Script Date: 11/20/2015 12:29:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- usp_s_UDMFieldChaltaNos 26,4,2,15,66,16207,'','','','','','',''
-- usp_s_UDMFieldChaltaNos 26,4,2,15,66,16207,'','','','','','',''
ALTER PROCEDURE [dbo].[usp_s_UDMFieldChaltaNos]
@DistrictCode int
,@TalukCode int
,@TownId int
,@ZoneId int
,@SectorId int
,@BlockId int
,@HouseNo nvarchar(50)
,@WardId int
,@PropertyNumber nvarchar(50)
,@DivisionNo nvarchar(50)
,@LocalAreaNoId int
,@PTSheetId int
,@CitySurveyNo nvarchar(50)
--satya--
as
begin
declare @par nvarchar(max)
declare @parMain nvarchar(max)
--SubChaltaNo is null and
set @par= ' where DistrictCode=' + convert(nvarchar(3),@DistrictCode)
set @parMain= ' where a.DistrictCode=' + convert(nvarchar(3),@DistrictCode)
set @par=@par + ' and TalukCode=' + convert(nvarchar(3),@TalukCode)
set @parMain=@parMain + ' and a.TalukCode=' + convert(nvarchar(3),@TalukCode)
set @par=@par + ' and TownId=' + convert(nvarchar(3),@TownId)
set @parMain=@parMain + ' and a.TownId=' + convert(nvarchar(3),@TownId)
set @par=@par +' and ChaltaId not in (select ChaltaId from UPOR_Property_Main where
DistrictCode='+ convert(nvarchar(3),@DistrictCode) +' and TalukCode='
+ convert(nvarchar(3),@TalukCode) +' and TownId= '+ convert(nvarchar(3),@TownId) +') '
if @ZoneId<>0
begin
set @par=@par + ' and ZoneId=' + convert(nvarchar,@ZoneId)
set @parMain=@parMain + ' and ZoneId=' + convert(nvarchar,@ZoneId)
end
if @SectorId<>0
begin
set @par=@par + ' and SectorId=' + convert(nvarchar,@SectorId)
set @parMain=@parMain + ' and SectorId=' + convert(nvarchar,@SectorId)
end
if @BlockId<>0
begin
set @par=@par + ' and BlockId=' + convert(nvarchar,@BlockId)
set @parMain=@parMain + ' and BlockId=' + convert(nvarchar,@BlockId)
end
if @WardId<>0
begin
set @par=@par + ' and WardId=' + convert(nvarchar,@WardId)
set @parMain=@parMain + ' and WardId=' + convert(nvarchar,@WardId)
end
if @LocalAreaNoId<>0
begin
set @par=@par + ' and LocalAreaNoId=' + convert(nvarchar,@LocalAreaNoId)
set @parMain=@parMain + ' and LocalAreaNoId=' + convert(nvarchar,@LocalAreaNoId)
end
if @PTSheetId<>0
begin
set @par=@par + ' and PTSheetId=' + convert(nvarchar,@PTSheetId)
set @parMain=@parMain + ' and PTSheetId=' + convert(nvarchar,@PTSheetId)
end
if @HouseNo<>''
begin
set @par=@par + ' and HouseNo = ' + char(39) + @HouseNo + char(39)
set @parMain=@parMain + ' and HouseNo = ' + char(39) + @HouseNo + char(39)
end
if @PropertyNumber<>''
begin
set @par=@par + ' and PropertyNumber = ' + char(39) + @PropertyNumber + char(39)
set @parMain=@parMain + ' and PropertyNumber = ' + char(39) + @PropertyNumber + char(39)
end
if @CitySurveyNo<>''
begin
set @par=@par + ' and CitySurveyNo = ' + char(39) + @CitySurveyNo + char(39)
set @parMain=@parMain + ' and CitySurveyNo = ' + char(39) + @CitySurveyNo + char(39)
end
set @par=@par + ' and isdeleted is null'
set @parMain=@parMain + ' and Type=''S''
and a.MainChaltaId in (select chaltaid from dbo.UPOR_Property_Main)
and a.MainChaltaId=b.chaltaid
and a.chaltaid not in (select chaltaid from dbo.UPOR_Property_Main) and isDeleted is null'
--(case when AdditionalNo IS Null then convert(varchar,ChaltaNo) else convert(varchar,ChaltaNo) +'+'''/''' +'+ AdditionalNo end )as ChaltaNo
--convert(varchar,isnull(AdditionalNo,'''')) as ChaltaNo
declare @query nvarchar(max)
declare @queryMain nvarchar(max)
set @query= 'select ChaltaId,
(Case when Additionalno is null and subchaltano is null then convert(varchar,chaltano)
when Additionalno is not null and subchaltano is null then convert(varchar,chaltano) +'+'''/'''+'+ additionalno
when Additionalno is null and subchaltano is not null then convert(varchar,chaltano) +'+'''-'''+'+ convert(varchar,subchaltano)
else convert(varchar,chaltano) +'+'''/'''+'+ additionalno +'+'''-'''+'+ convert(varchar,subchaltano) end) as ChaltaNo
from UPOR_ChaltaMain'
-- convert(varchar,isnull(AdditionalNo,''''))
--as ChaltaNo
set @queryMain=' UNION select distinct a.chaltaid,
(Case when a.Additionalno is null and a.subchaltano is null then convert(varchar,a.chaltano)
when a.Additionalno is not null and a.subchaltano is null then convert(varchar,a.chaltano) +'+'''/'''+'+ a.additionalno
when a.Additionalno is null and a.subchaltano is not null then convert(varchar,a.chaltano) +'+'''-'''+'+ convert(varchar, a.subchaltano)
else convert(varchar,a.chaltano)+'+'''/'''+'+ a.additionalno +'+'''-'''+'+ convert(Varchar,a.subchaltano) end) as ChaltaNo
from UPOR_ChaltaMain as a,UPOR_Property_Main as b'
set @queryMain=@queryMain + @parMain
set @query=@query+@par
set @query = @query + @queryMain
--where
-- DistrictCode='+ convert(varchar,@census_dist_code) +' and TalukCode='+ convert(varchar,@census_taluk_code) +'
-- and TownId=' + convert(varchar,@TownId) + convert(varchar,@WhrVal)
declare @queryUNION nvarchar(max)
set @queryUNION='select distinct chaltaid,ChaltaNo from ('+@query+') as c '+' where ChaltaId !=0 '
print (@queryUNION)
exec (@queryUNION)
end
--
|
|
|
|
|
Don't post in multiple areas. It's considered rude.
As I told you in QA, your problem is that the sql is dynamic so the number of return columns cannot be determined ahead of time. Use something other than EF for this one.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have Visual Studio 2010 Professional which should have the chart control in the toolbox. It is checked as being in the toolbox for both web forms and windows forms, but it is not showing. Is there some way to fix this? My projects are VB.
Bobby
|
|
|
|
|
You could always try adding it anyway in to your page and see if it takes or if you get an error that might tell you what is happening.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Ryan,
Thank you. I resolved the issue thus: Loaded Visual Web Developer 2008 and added chart control to the toolbox. Opened VS 2010, unchecked chart controls from the Add Controls Dialog. Then added them back. Voila! Now the chart control appears in the vs 2010 toolbox.
Windows update kept trying to install update for the control, and failed for 5 days. Now the update should work. Hope this helps anyone who is experiencing a similar problem.
Bobby
|
|
|
|
|
i have a problem using the auto complete with oracle, when i use @SearchText i don't now how fix it
Imports System.Collections.Generic
Imports System.Data.OracleClient
Imports System.Data
Partial Class VB
Inherits System.Web.UI.Page
<System.Web.Script.Services.ScriptMethod(), _
System.Web.Services.WebMethod()> _
Public Shared Function SearchCustomers(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim conn As OracleConnection = New OracleConnection
conn.ConnectionString = ConfigurationManager _
.ConnectionStrings("conexss").ConnectionString
Dim cmd As OracleCommand = New OracleCommand
cmd.CommandText = "select SITIOSEDENAME from INV_SITIOSEDE where " & _
"SITIOSEDENAME like @SearchText || '%'"
cmd.Parameters.AddWithValue("@SearchText", prefixText)
cmd.Connection = conn
conn.Open()
Dim customers As List(Of String) = New List(Of String)
Dim sdr As OracleDataReader
sdr = cmd.ExecuteReader
While sdr.Read
customers.Add(sdr("SITIOSEDENAME").ToString)
End While
conn.Close()
Return customers
End Function
Public Function SearchCustomers() As System.String[]
End Function
End Class
|
|
|
|
|
You haven't told us what the problem is, but I'm guessing it's because you're using the wrong parameter prefix.
The OracleCommand class doesn't use @ as the parameter prefix; it uses : instead.
When using named parameters in an SQL statement called by an OracleCommand of CommandType.Text , you must precede the parameter name with a colon (: ). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding OracleParameter objects to the Parameters property), do not precede the named parameter with a colon.
cmd.CommandText = "select SITIOSEDENAME from INV_SITIOSEDE where SITIOSEDENAME like :SearchText || '%'"
cmd.Parameters.AddWithValue("SearchText", prefixText)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I've been looking around for some ideas or code for encrypting data like email addresses in c# for my MVC project.
I wrote some code in vb about 8 years back, wanted to beef it up this time, perhaps go 512K or higher. Cryptography is not one of my strong points. But I'm looking for suggestions on something rock solid.
[Edit]
The code I wrote is DES, guess I should go AES so I can use the Xeon CPU AES feature to make it faster, plus I'm now reading that DES is pretty unsecure.
I found this in code project. Not sure if I should adopt it or not. [Edit], I think I'll pass on this one and keep looking.
C# AES 256 bits Encryption Library with Salt[^]
|
|
|
|
|
jkirkerx wrote: C# AES 256 bits Encryption Library with Salt[^] That is very similar to what I use and as far as I know, still very secure.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Oh thanks!,
I didn't see that one. Looks good so far.
|
|
|
|
|
I'm using MSChart in my asp.net website. When I test my website on local host (my pc) it's work without any problem and shows the chart items completely, but when I publish and upload that on somee.com site for test, the chart isn't show as well .
Here is my web config code :
<configuration>
<configSections>
</configSections>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;Url=./TempImages/;deleteAfterServicing=false;privateImages=false" />
</appSettings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<defaultDocument>
<files>
<add value="login.aspx" />
</files>
</defaultDocument>
<handlers>
<remove name="ChartImageHandler"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</handlers>
</system.webServer>
<connectionStrings>
<add name="ConnectionString" connectionString="workstation id=database8.mssql.somee.com;packet size=4096;user id=AABSoftware_SQLLogin_1;pwd=vlnk44szmf;data source=database8.mssql.somee.com;persist security info=False;initial catalog=database8"/>
<add name="ConnectionString2" connectionString="workstation id=database8.mssql.somee.com;packet size=4096;user id=AABSoftware_SQLLogin_1;pwd=vlnk44szmf;data source=database8.mssql.somee.com;persist security info=False;initial catalog=database8"/>
<add name="ConnectionString3" connectionString="workstation id=database8.mssql.somee.com;packet size=4096;user id=AABSoftware_SQLLogin_1;pwd=vlnk44szmf;data source=database8.mssql.somee.com;persist security info=False;initial catalog=database8"/>
</connectionStrings>
<system.web>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false"/>
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
<compilation targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
<buildProviders>
</buildProviders>
</compilation>
</system.web>
</configuration>
|
|
|
|
|
Something clearly is not getting deployed. You should see an error somewhere.
What does show?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Guys
Is this forum for MVC too? or is there any separate forum for MVC?
|
|
|
|
|
John C Rayan wrote: Is this forum for MVC too? or is there any separate forum for MVC? No, since MVC is ASP.Net, this is the correct forum. CP has not created a specific MVC forum.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Hello
I am trying to use a DetailsView to insert a neew item into a db table.
The problem is, I organized all not knowing the table's schema a priori. I use a Gridview to visualize and update the table , and it all works correctly by binding dynamically the gridview to the table in the PageLoad event handler. I don't use any template.
When I try to do something similar to insert a new row using a dynamically bound detailsview , I correctly visualize the fields' names in the detailsview, but as I modify the values, and try to manage the insert event , I find into the DetailsViewInsertEventArgs parameter that the Values collection property only has the Keys subcollection correctly populated, but the Values are all empty . I would expect, but maybe I didn't understand well, the Values.Values subcollection to be populated with the values I inserted, just as find the Values.Keys subcollection populated with the fiedls' names. Is it due to the fact that I am bindingg dynamically ? is there a way to work around this limitation ?
|
|
|
|
|
To make things clearer here is my marlup :
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Insert.aspx.cs" Inherits="DBManagerWebForm.Insert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Insert" Height="50px" Width="125px" AutoGenerateInsertButton="True" OnItemInserting="DetailsView1_ItemInserting" OnItemUpdating="DetailsView1_ItemUpdating">
</asp:DetailsView>
<%----%>
<asp:Button ID="btnCancel" runat="server" OnClick="btnCancel_Click" Text="Go Back" />
<br />
<asp:TextBox ID="txtError" runat="server" ReadOnly="True" TextMode="MultiLine" Width="411px"></asp:TextBox>
</asp:Content>
and this is the codebehind :
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
int i;
SqlDbType T;
try
{
string Cmd = "INSERT INTO " + TABLE + " (";
IEnumerator En = e.Values.Keys.GetEnumerator();
En.Reset();
for (i = 0; i < e.Values.Count - 1; i++)
{
En.MoveNext();
Cmd += En.Current.ToString() + ",";
}
En.MoveNext();
Cmd += En.Current.ToString() + ") VALUES (";
string val;
En.Reset();
for (i = 0; i < e.Values.Count - 1; i++)
{
En.MoveNext();
T = Util.GetSqlType(DT.Columns[i].DataType);
val = e.Values[En.Current] == null ? "" : e.Values[En.Current].ToString();
if (T == SqlDbType.NVarChar)
Cmd += "'" + val + "',";
else
Cmd += val + ",";
}
En.MoveNext();
T = Util.GetSqlType(DT.Columns[i].DataType);
val = e.Values[En.Current] == null ? "" : e.Values[En.Current].ToString();
if (T == SqlDbType.NVarChar)
Cmd += "'" + val + "')";
else
Cmd += val + ")";
string ConnStr = WebConfigurationManager.ConnectionStrings[CONNECTION].ConnectionString;
SqlConnection Conn = new SqlConnection(ConnStr);
Conn.Open();
SqlCommand Comm = new SqlCommand(Cmd, Conn);
int r = Comm.ExecuteNonQuery();
Conn.Close();
Server.Transfer("~/modifica.aspx");
}
catch (Exception ex)
{
txtError.Text = "Errore :" + ex.Message;
}
}
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
SQL injection attack mechanics | Pluralsight [^]
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
string ConnStr = WebConfigurationManager.ConnectionStrings[CONNECTION].ConnectionString;
using (SqlConnection connection = new SqlConnection(ConnStr))
using (SqlCommand command = new SqlCommand("", connection))
{
string[] columns = new string[e.Values.Count];
int index = 0;
foreach (string key in e.Values.Keys)
{
command.Parameters.AddWithValue("@" + key, e.Values[key]);
columns[index] = key;
index++;
}
command.CommandText = string.Format("INSERT INTO [{0}] ({1}) VALUES (@{2})",
TABLE, string.Join(", ", columns), string.Join(", @", columns));
connection.Open();
command.ExecuteNonQuery();
}
Server.Transfer("~/modifica.aspx");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
please any one can give me source code for create,update,read and delete in asp.net with c# coding
|
|
|
|
|
|