using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Sql;
using System.Data.SqlClient;
namespace WebApplication9
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
getcategory();
}
void getcategory()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=HOME\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_products3";
cmd.Connection = conn;
try
{
conn.Open();
SqlDataReader datareader = cmd.ExecuteReader();
while (datareader.Read())
{
ListBox1.Items.Add(datareader.ToString());
}
datareader.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Close();
}
}
void getproductcategory()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=HOME\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_productid1";
cmd.Connection = conn;
SqlParameter param = new SqlParameter();
param.ParameterName = "@ProductSubcategoryID";
Convert.ToInt64(הבעיה היא כאן!);
try
{
conn.Open();
SqlDataReader datareader = cmd.ExecuteReader();
while (datareader.Read())
{
ListBox2.Items.Add(datareader.ToString());
}
datareader.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
ListBox1.Visible = false;
Button1.Visible = false;
ListBox2.Visible = true;
Button2.Visible = true;
getproductcategory();
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}