redirect page in asp.net
-
hello very one ;) i need some help or advice from the people , who have expert in asp.net this is my problem the url for example is http://localhost:2940/website/page.aspx?ID=1 when i change id to http://localhost:2940/website/page.aspx?ID=100000000000000000000000000000000000 i get error manege The conversion of the nvarchar value '20000000000000000000000000000000' overflowed an int column. i need if the ID dose not exist in database table , redirect the page to homepage thx all
-
hello very one ;) i need some help or advice from the people , who have expert in asp.net this is my problem the url for example is http://localhost:2940/website/page.aspx?ID=1 when i change id to http://localhost:2940/website/page.aspx?ID=100000000000000000000000000000000000 i get error manege The conversion of the nvarchar value '20000000000000000000000000000000' overflowed an int column. i need if the ID dose not exist in database table , redirect the page to homepage thx all
I believe you are converting this value into int type and it's exceeding the max size. So use Long type.
Parwej Ahamad
-
hello very one ;) i need some help or advice from the people , who have expert in asp.net this is my problem the url for example is http://localhost:2940/website/page.aspx?ID=1 when i change id to http://localhost:2940/website/page.aspx?ID=100000000000000000000000000000000000 i get error manege The conversion of the nvarchar value '20000000000000000000000000000000' overflowed an int column. i need if the ID dose not exist in database table , redirect the page to homepage thx all
there is 2 way to handle this issue 1) increase the size of Column of id in database 2) before executing query for existing of id check length of ID if it is less then the column size then go ahead. else return false from there no need to execute query. I prefer to use 2nd method. Remember one thing that when you execute sql query always check length of fields which you are using in query. :) Thanks
As our case is new, we must think and act a new. Abraham Lincoln
-
hello very one ;) i need some help or advice from the people , who have expert in asp.net this is my problem the url for example is http://localhost:2940/website/page.aspx?ID=1 when i change id to http://localhost:2940/website/page.aspx?ID=100000000000000000000000000000000000 i get error manege The conversion of the nvarchar value '20000000000000000000000000000000' overflowed an int column. i need if the ID dose not exist in database table , redirect the page to homepage thx all
In the Page_Load event...
[put code to check if ID is valid here, then. . .]
If (NotValid)
{
Server.Transfer("Default.aspx");
}
else
{
DoAllTheNormalStuff();
}Just like that old Carly Simon song... "You're so funny, You probably think this joke is about you" My Mu[sic] My Films My Windows Programs, etc.
-
In the Page_Load event...
[put code to check if ID is valid here, then. . .]
If (NotValid)
{
Server.Transfer("Default.aspx");
}
else
{
DoAllTheNormalStuff();
}Just like that old Carly Simon song... "You're so funny, You probably think this joke is about you" My Mu[sic] My Films My Windows Programs, etc.
-
hello very one ;) i need some help or advice from the people , who have expert in asp.net this is my problem the url for example is http://localhost:2940/website/page.aspx?ID=1 when i change id to http://localhost:2940/website/page.aspx?ID=100000000000000000000000000000000000 i get error manege The conversion of the nvarchar value '20000000000000000000000000000000' overflowed an int column. i need if the ID dose not exist in database table , redirect the page to homepage thx all
Try this but the code is in vb,get the idea and convert to C#(if you use C#)
Private Function CheckID(ByVal strID As String)
Dim strSQL As String
Dim conn As New OracleConnection
Dim reader As System.Data.OracleClient.OracleDataReaderstrSQL = "Select ID From Where ID = '" & strID & "'"
Dim cmd = New OracleCommand(strSQL , conn)
reader = cmd.ExecuteReader()
If reader.Read() Then
If reader.HasRows Then
Return True
Else
Return False
End If
Return ""
End IFIn your page load or load complete,call CheckID() and insert ID into it.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If CheckID("") = True Then
Response.Redirect("newpage.aspx")
Else
Response.Write("Error. There is no page ID in our database"
End If