sql server - Gridview not returning rows properly in aspx page -


I have to create a stored procedure that will search through rows of matching in the database and show them in gridview. Users can search through the selection of an option, some options are not mandatory

I have created a stored procedure but the result only appears when I am executing it in SQL Server Management Studio Console I am The stored procedure is not showing any records in the Gridview page in the ASPX page.

Please help me find out if I am doing anything wrong here.

The stored procedure I created is as follows:

  ALTER PROCEDURE dbo.ProcName @abc varchar (50) = null, @def varchar (50) = null , @ Ghi int = null, @jkl varchar (50) = null, @mno varchar (50) = Select abc, def, gh, jkl, mno, rst from the tap table name (@abc is null or abc = @abc) and (@def IS nULL oR def = @def) and (@ghi IS nULL oR ghi = @ghi) and (@jkl IS nULL or jkl = @jkl) and (@ Manai tap or Mno = @ MO ) And go   

Here is the code I'm using in the asp.net page to show records in Gridwove:

  sub showResult (object's in the form of Rot, EventArgs as e) dim oConn SqlConnection Dim oComm SqlCommand SqlDataAdapter as dim da Dim ds dataset dim sSQL String Dim sConn string dim strloc, listtype, roomno, present, fantasy, Forrent, price, area, email strloc = as as as as as List_Location.SelectedItem.Text Listtype = List_Type.SelectedItem.Text roomno = List_RoomNo.SelectedItem.Value furnishing = List_Furnishing.SelectedItem.Text forrent = List_RentSale.SelectedItem. Value sConn = ConfigurationManager.ConnectionStrings ("xyz"). ConnectionString oConn = New SQLConnection (sConn) oComm = New SQLCommand ("SearchP", oConn) oConn.Open () oComm.CommandType = CommandType.StoredProcedure oComm.Parameters.Add (New SqlParameter ("@ abc", SqlDbType.VarChar, 50 )) OComm.Parameters ("@ ABC"). Value = strloc oComm.Parameters.Add (New SqlParameter ("@ def", SqlDbType.VarChar, 50)) oComm .Parameters ("@ DEF"). Value = listtype oComm.Parameters.Add (New SqlParameter ("@GHI", SqlDbType.Int) oComm.Parameters ("@GHI"). Value = roomno oComm.Parameters.Add (New SqlParameter ("@JKL", SqlDbType.VarChar, 50)) oComm.Parameters ("@JKL"). Value = OCommkParameterskAdd (new SqlParameter ( "@ MNO", SqlDbType.VarChar, 50 submitted)) oComm .Parameters ( '@ MNO ".) Value = forrent da = new SqlDataAdapter (oComm) ds = new DataSet ( ) try panel1.visible = "true" da.Fill (DS, "TableName") myGridView.DataSource = ds.Tables ( "Teblnam"). DefaultView myGridView.EmptyDataText = "no records found" myGridView.DataBind ( ) try to grab as former Ception lblResults.text = ex.Message end oComm.Dispose () oConn.Dispose () oConn.Close (the) end    

< Div class = "post-text" itemprop = "text">

Evaluates your stored procedure parameter, either @abcsh NY or abc = @abc is. This means that you will have a null value pair to advisory Aspiaks page if the user does not supply its own value Aspiaks page a nULL value is not passed in the procedure to store a null binding, so it will always evaluate column = [blank value] , or ABC = [Empty value] . Is

item at the top of the list as the list web page ( '0' position) that a list of calls to choose, then ASPX code should look something like this: < / p>

  If List_Location.ItemIndex = 0 then oComm.Parameters.AddWithValue ( "@ abc", DBNull.Value) or oComm.Parameters.AddWithValue ( "@ abc", List_ Lokeshnkcynit items. text )   

the way the user chooses not to have any value when you close null , or when they assume. Your stored procedure must be able to correctly use the @abc zero or abc = @abc syntax.

Comments