SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    402
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Query does not wrap

    Query does not wrap

    Hi all.

    Why this query response with error: ?

    PHP Code:
    <script runat="server">
      protected 
    override void OnInit(EventArgs e)
      {
        
    base.OnInit(e);

        
    using(OdbcConnection con = new OdbcConnection(ConnStr))
        
    using(OdbcCommand cmd = new OdbcCommand
        
        
    ("SELECT * FROM _tbl " &_
         
    "WHERE 1 AND NAME <> 'NULL' LIMIT 0, 20"con))
        
        {
          
    con.Open();
          
    dgrAllNames.DataSource cmd.ExecuteReader(
          
    CommandBehavior.CloseConnection 
          
    CommandBehavior.SingleResult);
          
    dgrAllNames.DataBind();
          
    con.Close();
        }
      }
    </script> 
    11: using(OdbcCommand cmd = new OdbcCommand
    12:
    13: ("SELECT * FROM _tbl " &_
    14: "WHERE 1 AND NAME <> 'NULL' LIMIT 0, 20", con))
    15:
    Can u help me?

  2. #2
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Miguel61 View Post
    Query does not wrap

    Hi all.

    Why this query response with error: ?

    PHP Code:
    <script runat="server">
      protected 
    override void OnInit(EventArgs e)
      {
        
    base.OnInit(e);

        
    using(OdbcConnection con = new OdbcConnection(ConnStr))
        
    using(OdbcCommand cmd = new OdbcCommand
        
        
    ("SELECT * FROM _tbl " &_
         
    "WHERE 1 AND NAME <> 'NULL' LIMIT 0, 20"con))
        
        {
          
    con.Open();
          
    dgrAllNames.DataSource cmd.ExecuteReader(
          
    CommandBehavior.CloseConnection 
          
    CommandBehavior.SingleResult);
          
    dgrAllNames.DataBind();
          
    con.Close();
        }
      }
    </script> 


    Can u help me?
    It's because your code is written in C#, but you are using VB.NET characters.Try...

    Code SQL:
     ("SELECT * FROM _tbl " +
         "WHERE 1 AND NAME <> 'NULL' LIMIT 0, 20", con))

  3. #3
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    402
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Thanks Sir.

    But I have another question, I'm sorry.

    With ASP I have this query:

    Code:
       strTIME = replace(time(), ".", ":")
       
       SQL = " SELECT * FROM "
       SQL = SQL & " tbl_1 "
       SQL = SQL & " WHERE "
       SQL = SQL & " myDate = '" & formatGMTDate(DATE(),0,"yyyy-mm-dd") & "' "
       
    if strTIME >= "00:00:00" AND strTIME =< "05:59:59" then   
       SQL = SQL & " AND "
       SQL = SQL & " _myTime BETWEEN '00:00:00' AND '05:59:59' "
    end if
    How do I write the same string with .net?
    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •