» »

Filtriranje SQL poizvedb na osnovi datuma ASP

Filtriranje SQL poizvedb na osnovi datuma ASP

brinovcek ::

Pozdravljeni,

Zanima me ali kdo vidi ali pa pozna rešitev pri mojem programčku, v katerem v GridView kontroli želim prikazati transakcije za določeno časovno obdobje (kot naprimer pregled prometa v NLB Kliku). Pri tem sem naletel na težavo saj se mi aplikacija vedno sesuje zaradi SQL stavka katerega sortiram z uporabo parametrov, ki jih dobim v 2 tekstovnih poljih. Zanima me kako bi slednjo zadevo predelal, da bi bila stabilna.

Struktura tabele v Bazi:
_____________________
Tr
_____________________
IzvorniIBAN nchar(19)
PonorniIBAN nchar(19)
Datum date
ZnesekPlacila money
NazivPlacila nvarchar(50)
Sklic nvarchar(50)
VrstaPosla nvarchar(50)
...
________________________

            string connStr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString.ToString();
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            SqlDataAdapter dAd = null;
            DataSet dSet = new DataSet();
            try
            {
                SqlCommand myCommand = new SqlCommand();
                myCommand.Connection = conn;
                myCommand.CommandText = "SELECT Datum, NazivPlacila, ZnesekPlacila, IzvorniIBAN "+
                "FROM Transakcije WHERE (IzvorniIBAN = @Param1) And Datum>'"+TextBox1.Text.ToString()+"'";
                
                myCommand.Parameters.AddWithValue("@Param1", DropDownList1.SelectedValue.ToString());
                
                dAd = new SqlDataAdapter(myCommand);
                dAd.Fill(dSet);

                GridView1.DataSource = dSet.Tables[0].DefaultView;
                GridView1.DataBind();

                Response.Write("Število vrstic"+dSet.Tables[0].Rows.Count);

            }
            catch (Exception ee)
            {
                Response.Redirect("Error occured.+" + ee.Message.ToString());
            }
            finally
            {
                dSet.Dispose();
                dAd.Dispose();
                conn.Close();
                conn.Dispose();
            }


Sporočilo ob napaki ...

A potentially dangerous Request.Path value was detected from the client"(<)".

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.Web.HttpException: A potentially dangerous Request.Path value was detected from the client"(<)".

Source Error: 

An unhandled exception was generated during the execution of the current web request. 
Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client "(<)".]
   System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +8909993
   System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +59

Vljudno prosim za pomoč...nujno.

Lp.

matonson ::

Nism lih stručko za te stvari, ampak vseeno.
Takole ne gre?:
myCommand.CommandText = "SELECT Datum, NazivPlacila, ZnesekPlacila, IzvorniIBAN "+
 "FROM Transakcije WHERE (IzvorniIBAN = @Param1) And Datum>@Datum";

myCommand.Parameters.AddWithValue("@Param1", DropDownList1.SelectedValue.ToString());
myCommand.Parameters.AddWithValue("@Datum", nekDatum);

Zgodovina sprememb…

  • spremenil: matonson ()

brinovcek ::

probal... ne gre :(

DubleG ::

myCommand.CommandText = "SELECT Datum, NazivPlacila, ZnesekPlacila, IzvorniIBAN FROM Transakcije WHERE IzvorniIBAN = @Param1 And Datum>@Datum"; 
myCommand.Parameters.AddWithValue("@Param1", DropDownList1.SelectedValue.ToString());
myCommand.Parameters.AddWithValue("@Datum", nekDatum);

Seveda gre.

Pazi da je "nekDatum" pravilnega formata.
GA-P55M-UD2,i5,12GB RAM,Radeon HD 4850,Crucial SSD 64GB,
WD 320GB,WD 5000GB,RevoDrive X2 100GB


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

C# težava

Oddelek: Programiranje
233801 (2647) mladec
»

[C#,SQL]

Oddelek: Programiranje
51260 (1173) JanOlMajti
»

C# INSERT statment ne vpise podatkov

Oddelek: Programiranje
111219 (1093) darkolord
»

C# OleDB create database

Oddelek: Programiranje
71326 (1158) DubleG
»

[C#] DATA GRID VIEW

Oddelek: Programiranje
131954 (1834) Kekec

Več podobnih tem