Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
I have looked into this a lot, but have not been able to find a solution to it.
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="c#" runat="server" debug="true" %>
- <%@ Import Namespace="System.Data" %>
- <%@ Import Namespace="System.Data.OleDb" %>
- <script runat="server">
- OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=************;Initial Catalog=******;User Id=******;Password='********';;");
- protected void Page_Load(Object Src, EventArgs E)
- {
- if (!IsPostBack)
- {
- if (Session["msg"] == null)
- {
- memberLogin.Visible = true;
- shoppingCart.Visible = false;
- rptMain.Visible = true;
- rptDetail.Visible = false;
- string loadSQL = "Select * From product";
- search(loadSQL);
- GetCats();
- }
- if (Session["msg"] == "Member Created!")
- {
- memberLogin.Visible = true;
- shoppingCart.Visible = false;
- lbUser.Text = "Login to your new account";
- string loadSQL = "Select * From product";
- search(loadSQL);
- GetCats();
- }
- if (Session["msg"] == "Please continue shopping")
- {
- memberLogin.Visible = false;
- shoppingCart.Visible = true;
- string loadSQL = "Select * From product";
- search(loadSQL);
- GetCats();
- GetCart(Session.SessionID);
- lbUser.Text = "Please continue shopping!";
- }
- if (Session["msg"] == "Your Profile has been updated!")
- {
- memberLogin.Visible = false;
- shoppingCart.Visible = true;
- string loadSQL = "Select * From product";
- search(loadSQL);
- GetCats();
- GetCart(Session.SessionID);
- lbUser.Text = "Your profile has been updated. The changes will take effect the next time you log in.";
- }
- if (Session["msg"] == "You have not updated your account!")
- {
- memberLogin.Visible = false;
- shoppingCart.Visible = true;
- string loadSQL = "Select * From product";
- search(loadSQL);
- GetCats();
- GetCart(Session.SessionID);
- lbUser.Text = "You have not updated your account!";
- }
- }
- }
- public void search(string sSQL)
- {
- rptDetail.Visible = false;
- rptMain.Visible = true;
- OleDbCommand CmdSch = new OleDbCommand(sSQL, conn);
- conn.Open();
- rptMain.DataSource = CmdSch.ExecuteReader();
- rptMain.DataBind();
- conn.Close();
- }
- public void logout(object s, EventArgs e)
- {
- string loadSQL = "Select * From product";
- search(loadSQL);
- memberLogin.Visible = true;
- shoppingCart.Visible = false;
- rptMain.Visible = true;
- rptDetail.Visible = false;
- GetCats();
- Session.Contents.RemoveAll();
- lbUser.Text = "You have successfully logged out.";
- }
- public void btLogin_Click(Object s, EventArgs e)
- {
- string logSQL = "Select cust_id, username, pword, fname, lname from Customer where username='" + tbUser.Text + "' and pword = '" + tbPass.Text + "'";
- OleDbDataAdapter logDA = new OleDbDataAdapter(logSQL, conn);
- string msg1 = "Record not found";
- DataSet logDS = new DataSet();
- logDA.Fill(logDS, "customer");
- int numRecs = logDS.Tables["customer"].Rows.Count;
- if(numRecs > 0)
- {
- foreach(DataRow logRow in logDS.Tables["customer"].Rows)
- {
- Session["customer"] = logRow[3].ToString() + " " + logRow[4].ToString();
- Session["cust_id"] = logRow[0].ToString();
- }
- lbUser.Text = "Welcome back, " + Session["customer"];
- memberLogin.Visible = false;
- shoppingCart.Visible = true;
- }
- else
- {
- lbUser.Text = msg1 + " - Please try your login again";
- }
- }
- public void cmdCheck(object sender, RepeaterCommandEventArgs e)
- {
- if (e.CommandName == "Details")
- {
- LinkButton lbtnSelected = new LinkButton();
- lbtnSelected.Text = ((LinkButton)e.CommandSource).Text;
- string sProduct = lbtnSelected.Text;
- string SQL8 = "Select * From Product where p_name = '" + lbtnSelected.Text + "'";
- showDetails(sProduct, SQL8);
- }
- if (e.CommandName == "AddToCart")
- {
- Label lbSelected = new Label();
- lbSelected = (Label) e.Item.FindControl("lbProduct_ID");
- Label priceSelected = new Label();
- priceSelected = (Label) e.Item.FindControl("lbPrice");
- string sPrice = priceSelected.Text;
- double dPrice;
- int at = sPrice.IndexOf("$");
- if (at == 0)
- {
- dPrice = Convert.ToDouble(sPrice.Remove(at, 1));
- }
- else
- {
- dPrice = Convert.ToDouble(sPrice);
- }
- string sProdID = lbSelected.Text;
- int prod_id = Convert.ToInt32(sProdID);
- string sProduct = e.CommandArgument.ToString();
- string SQL9 = "SELECT * FROM product WHERE product_id = '" + prod_id + "'";
- AddToCart(prod_id, dPrice, sProduct, SQL9);
- }
- }
- public void showDetails(string sProduct, string sSQL)
- {
- lbHeader.Text = "Details For: " + sProduct;
- OleDbCommand cmd8 = new OleDbCommand(sSQL, conn);
- conn.Open();
- rptDetail.DataSource = cmd8.ExecuteReader();
- rptDetail.DataBind();
- conn.Close();
- rptMain.Visible = false;
- rptDetail.Visible = true;
- }
- void AddToCart(int product_id, double price, string p_name, string sSQL1)
- {
- if (Session["cust_id"] == null)
- {
- lbUser.Text = "<b>YOU MUST LOG IN BEFORE ORDERING!!</b>";
- lbUser.Visible = true;
- }
- else
- {
- string checkCart = "SELECT prod_id FROM Items WHERE product_id = prod_id";
- OleDbDataAdapter logDACart = new OleDbDataAdapter(checkCart, conn);
- DataSet logDSCart = new DataSet();
- logDACart.Fill(logDSCart, "Items");
- int numRecsCart = logDSCart.Tables["Items"].Rows.Count;
- if(numRecsCart > 0)
- {
- lbUser.Text = "You already have that item in your cart!";
- }
- else
- {
- string sessionNum = Session.SessionID;
- int cust_id = Convert.ToInt32(Session["cust_id"]);
- string SQLcart = "INSERT INTO Items (sess_ID, cust_id, prod_id, prod_name, prod_price) VALUES ('" + sessionNum + "', " + cust_id + ", " + product_id + ", '" + p_name + "', " + price + ")";
- OleDbCommand insCart = new OleDbCommand(SQLcart, conn);
- conn.Open();
- insCart.ExecuteNonQuery();
- conn.Close();
- GetCart(sessionNum);
- }
- }
- }
- public void GetCart(string sessNum)
- {
- string SQLgetCart = "SELECT * FROM items WHERE cust_id = " + Session["cust_id"] + " AND sess_ID = '" + sessNum + "'";
- OleDbCommand cmdGetCart = new OleDbCommand(SQLgetCart, conn);
- conn.Open();
- dlsCart.DataSource = cmdGetCart.ExecuteReader();
- dlsCart.DataBind();
- conn.Close();
- lbCart.Text = "Your Selections:";
- btClearCart.Visible = true;
- lnkViewCart.Visible = true;
- lbUser.Text = "Cart available for " + Session["customer"];
- }
- void ClearCartClick(object s, EventArgs e)
- {
- clearcart();
- }
- public void clearcart()
- {
- string SessNo = Session.SessionID;
- string SQLclearCart = "Delete FROM Items WHERE cust_id = " + Session["cust_id"] + " AND sess_ID = '" + SessNo + "'";
- OleDbCommand cmdClearCart = new OleDbCommand(SQLclearCart, conn);
- conn.Open();
- cmdClearCart.ExecuteNonQuery();
- conn.Close();
- GetCart(SessNo);
- lbCart.Text = "Your Cart is Empty";
- btClearCart.Visible = false;
- lnkViewCart.Visible = false;
- lbUser.Text = Session["customer"] + "'s Cart Emptied";
- }
- public void GetCats()
- {
- string catSQL = "Select * From lookCategory";
- OleDbCommand cmdCat = new OleDbCommand(catSQL, conn);
- conn.Open();
- ddlCat.DataSource = cmdCat.ExecuteReader();
- ddlCat.DataTextField = "Category";
- ddlCat.DataValueField = "Category";
- ddlCat.DataBind();
- ddlCat.Items.Insert(0, new ListItem("<-select->", ""));
- conn.Close();
- }
- public void buildCats(Object s, EventArgs e)
- {
- string SQL1 = "Select * From product Where Category = '" + ddlCat.SelectedItem.Value + "'";
- lbHeader.Text = "Search: Categories: " + ddlCat.SelectedItem.Value;
- search(SQL1);
- }
- </script>
if (Session["msg"] == null)
{
memberLogin.Vis ible = true;
shoppingCart.Vi sible = false;
rptMain.Visible = true;
rptDetail.Visib le = false;
string loadSQL = "Select * From product";
search(loadSQL) ; <<<<<<<<<<<<<<< <<<<<<
GetCats();
and
public void search(string sSQL)
{
rptDetail.Visib le = false;
rptMain.Visible = true;
OleDbCommand CmdSch = new OleDbCommand(sS QL, conn);
conn.Open(); <<<<<<<<<<<<<<< <<<<
rptMain.DataSou rce = CmdSch.ExecuteR eader();
rptMain.DataBin d();
conn.Close();
}
I've read around that I need to use a MySQL provider. So I download the provider, install it, then I get an error saying that the provider is not on the local machine, Ok whatever. I then read that I should have a OCDB connetor....sam e thing, doesn't show up on my local machine.
This came from a test server and it just now experiencing these problems. I'm thinking that it may just be the fact that I can't get the MySQL provider or the OCDB connector on my computer here, but I have downloaded/installed them both multiple times from different sources. There is only one record in the DB to test with, so its not a problem of mixed values somewhere.
I'm really having a problem here.
Any ideas and help would be much appreciated.