safetyweek Posted March 8, 2011 Share Posted March 8, 2011 Query does not wrapHi all.Why this query response with error: ? <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 OdbcCommand12: 13: ("SELECT * FROM _tbl " &_14: "WHERE 1 AND NAME <> 'NULL' LIMIT 0, 20", con))15:Can u help me? Link to comment Share on other sites More sharing options...
davej Posted March 9, 2011 Share Posted March 9, 2011 ("SELECT * FROM _tbl " &_Try("SELECT * FROM _tbl " & _Note the added space.Also...WHERE 1 AND NAME <> 'NULL' LIMIT 0, 201 what? TryWHERE NAME IS NOT NULL LIMIT 20 Link to comment Share on other sites More sharing options...
safetyweek Posted March 11, 2011 Author Share Posted March 11, 2011 Thanks Sir, I fixed with: using(OdbcCommand cmd = new OdbcCommand(" SELECT * FROM _tbl " + " WHERE " + " NAME <> 'NULL' LIMIT 0, 20 ", con)) But I have another question, I'm sorry.With ASP I have this query: 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 Link to comment Share on other sites More sharing options...
davej Posted March 13, 2011 Share Posted March 13, 2011 using(OdbcCommand cmd = new OdbcCommand(" SELECT * FROM _tbl " + " WHERE " + " NAME <> 'NULL' LIMIT 0, 20 ", con)) I don't think that will really work. Be sure to test it with real nulls.For the date question look at;http://msdn.microsoft.com/en-us/library/sy...v=VS.90%29.aspx I've used this code for SQL Server; sql = "SELECT COUNT(*) " & _ "FROM PAYROLL " & _ "WHERE Employee_Valid IS Null " & _ " AND RTRIM(CONVERT(char(12), PayDate,101)) = '" & pdate & "' " Link to comment Share on other sites More sharing options...
safetyweek Posted March 15, 2011 Author Share Posted March 15, 2011 Thanks Sir- Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.