En iyi yanıtlayıcılar
Incorrect syntax near the keyword 'where'. (select * from WAlbum where Active=1 and where ID='1' order by Row desc)

Soru
-
Incorrect syntax near the keyword 'where'. (select * from WAlbum where Active=1 and where ID='1' order by Row desc)
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.Exception: Incorrect syntax near the keyword 'where'. (select * from WAlbum where Active=1 and where ID='1' order by Row desc)
Source Error:Line 45: catch (SqlException ex) Line 46: { Line 47: throw new Exception(ex.Message + " (" + sql + ")"); Line 48: } Line 49: adapter.Dispose();
Source File: c:\Users\GCL\Documents\Visual Studio 2010\WebSites\GC\App_Code\dbs.cs Line: 47
Stack Trace:[Exception: Incorrect syntax near the keyword 'where'. (select * from WAlbum where Active=1 and where ID='1' order by Row desc)] dbs.GetDataTable(String sql) in c:\Users\GCL\Documents\Visual Studio 2010\WebSites\GC\App_Code\dbs.cs:47 Works.rptWAlbum_ItemCommand(Object source, RepeaterCommandEventArgs e) in c:\Users\GCL\Documents\Visual Studio 2010\WebSites\GC\Works.aspx.cs:31 System.Web.UI.WebControls.Repeater.OnItemCommand(RepeaterCommandEventArgs e) +115 System.Web.UI.WebControls.Repeater.OnBubbleEvent(Object sender, EventArgs e) +68 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.RepeaterItem.OnBubbleEvent(Object source, EventArgs e) +121 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
<asp:Repeater ID="rptWAlbum" runat="server" OnItemCommand="rptWAlbum_ItemCommand"> <ItemTemplate> <div class="img"> <h3 class="desc"> <%# Eval("AlbumName") %></h3> <asp:ImageButton ID="imgAbum" runat="server" CommandName="album" CommandArgument='<%# Eval("ID") %>' CssClass="img" AlternateText='<%# Eval("AlbumName") %>' /> </div> </ItemTemplate> </asp:Repeater> <div id="works-right" class="right"> <h3> KATEGORİLER</h3> <hr /> <asp:Repeater ID="rptCats" runat="server" OnItemCommand="rptWAlbum_ItemCommand"> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate> <li>- <asp:LinkButton ID="lbLastBlogTitle" runat="server" CommandName="cats" CommandArgument='<%# Eval("ID") %>'><%# Eval("CatName") %></asp:LinkButton></li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> <br /> </div>
dbs db = new dbs(); protected void Page_Load(object sender, EventArgs e) { rptWAlbum.Visible = false; rptWPhoto.Visible = false; if (!IsPostBack) { rptCats.DataSource = db.GetDataTable("select * from WCats where Active=1 order by Row desc"); rptCats.DataBind(); } } protected void rptWAlbum_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "cats") { rptWAlbum.Visible = true; rptWAlbum.DataSource = db.GetDataTable("select * from WAlbum where Active=1 and where ID='" + e.CommandArgument + "' order by Row desc"); rptWAlbum.DataBind(); } else { lblW.Text = "Gösterilecek veri yok."; } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Configuration; using System.Data; /// <summary> /// Summary description for dbs /// </summary> public class dbs { public dbs() { // // TODO: Add constructor logic here // } public SqlConnection baglan() { string _connectionString = ConfigurationManager.ConnectionStrings["CS"].ConnectionString; SqlConnection _connection = new SqlConnection(_connectionString); _connection.Open(); return _connection; } public SqlCommand GetSqlCommand(string sql) { SqlConnection baglanti = this.baglan(); SqlCommand cmd = new SqlCommand(sql, baglanti); return cmd; } public DataTable GetDataTable(string sql) { SqlConnection baglanti = this.baglan(); SqlDataAdapter adapter = new SqlDataAdapter(sql, baglanti); DataTable dt = new DataTable(); try { adapter.Fill(dt); } catch (SqlException ex) { throw new Exception(ex.Message + " (" + sql + ")"); } adapter.Dispose(); baglanti.Close(); baglanti.Dispose(); return dt; } public DataSet GetDataSet(string sql) { SqlConnection baglanti = this.baglan(); SqlDataAdapter adapter = new SqlDataAdapter(sql, baglanti); DataSet ds = new DataSet(); try { adapter.Fill(ds); } catch (SqlException ex) { throw new Exception(ex.Message + " (" + sql + ")"); } adapter.Dispose(); baglanti.Close(); baglanti.Dispose(); return ds; } public int Command(SqlCommand sqlcumle) { SqlConnection baglan = this.baglan(); sqlcumle.Connection = baglan; int sonuc = 0; try { sonuc = sqlcumle.ExecuteNonQuery(); } catch (SqlException ex) { throw new Exception(ex.Message + " (" + sqlcumle + ")"); } sqlcumle.Dispose(); baglan.Close(); baglan.Dispose(); return (sonuc); } public string GetDataCell(string sql) { DataTable table = GetDataTable(sql); if (table.Rows.Count == 0) return null; return table.Rows[0][0].ToString(); } }
sorun nerede olabilir?
1881-193∞
mkayar86[at]gmail[nokta]com
www.facebook.com/mkayar86
http://www.twitter.com/kayarmelih
Yanıtlar
Tüm Yanıtlar
-
-
çok teşekkürler gözden kaçırmışım...
1881-193∞
mkayar86[at]gmail[nokta]com
www.facebook.com/mkayar86
http://www.twitter.com/kayarmelih