Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
W

WickedFooker

@WickedFooker
About
Posts
10
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Drop Down Listnot updating when item deleted from GridView
    W WickedFooker

    FIXED! I hard coded the Delete Command to the Grid like this:

    In the code back did this:

    protected void LinkButton_Click(Object sender, CommandEventArgs e)
    {

        if (e.CommandArgument != null)
        {
            
            string MainString = e.CommandArgument.ToString();
            string\[\] Split = MainString.Split(new Char\[\] { '&' });
            //SHOW RESULT of SPLIT
            Session\["ClassID"\] = (Convert.ToString(Split\[0\]));
            Session\["StudID"\] =  (Convert.ToString(Split\[1\]));
                        
            clsDataLayer.RemoveSchedule(Server.MapPath("eAcademy\_DB.mdb"),(String)Session\["StudID"\],(String)Session\["ClassID"\]);
    
            PopClass();
            PopStud();
            gvTeachers.DataBind();
            Session\["ClassID"\] = null;
            Session\["StudID"\] = null;    
        }
    
    }
    

    AND Lastly in my clsdatalayer:

    public static void RemoveSchedule(String path, String StudX, String ClassX)
    {
    //declaring database variables to access the database Addressbook
    OleDbConnection dbConn = null;
    OleDbCommand dbCmd;
    OleDbDataReader dr;
    String strConnection;
    String strSQL;

            {
                strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
                dbConn = new OleDbConnection(strConnection);
                dbConn.Open();
                strSQL = "DELETE \* FROM tblSchedule WHERE (class\_ID=? and stud\_ID=?)";
                dbCmd = new OleDbCommand(strSQL, dbConn);
                dbCmd.Parameters.Add(new OleDbParameter("class\_ID", ClassX));
                dbCmd.Parameters.Add(new OleDbParameter("stud\_ID", StudX));
                dr = dbCmd.ExecuteReader();
                dr.Read();
                dbConn.Close();
                
    
            }
            
        }
    

    Now to just add back the TRY Catch and it should be working nicely.

    ASP.NET css help design sysadmin question

  • Drop Down Listnot updating when item deleted from GridView
    W WickedFooker

    I have a drop down list that is populated by reading the student's names that have less than 3 classes in a semester. It is also reading a class list that has a population of less than 10. I can get it to work if i ADD a NEW student and then that student has reached 3 classes it will remove his name from the drop down, and the same with the class when I click add it removes BOTH the student (if over 3) and the class (if more than 10). However .. Here is the problem. When I delete a student from the schedule it does not update the drop down list. I have several databinds() but it does not appear to fix things. Ideally when it deletes a student from a class and let's say that student was formerly locked out (i.e. has 3 classes) - well then he has 2 and it should add his name if so to the drop down list (which is not updating). Thew same with CLASS since he dropped the class the count went down and if the class was full before it might not be now. Appreciate any insight you can offer. Weird how it works one way but not the other. In other words the grid is what is causing the problem - it updates but not the top part (drop down) even though I have databinds. Here is the code:

    using System;
    using System.Data;
    using System.Data.OleDb;
    using System.Web.UI.WebControls;

    public partial class frmRegisterStudent : System.Web.UI.Page
    {
    private void PopClass()
    {
    // Populate Class and add Please Select
    // Populate Student and add Please Select
    string path = Server.MapPath("eAcademy_DB.mdb");
    string connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
    string commandText10 = "SELECT class_ID FROM tblClass WHERE class_ID NOT IN (SELECT class_ID FROM tblschedule GROUP BY class_ID HAVING COUNT(class_ID) >= 10)";

        var ds10 = new DataSet();
    
        using (var connection10 = new OleDbConnection(connectionString))
        using (var command = new OleDbCommand(commandText10, connection10))
        {
            // OleDbCommand uses positional, rather than named, parameters.
            // The parameter name doesn't matter; only the position.
            command.Parameters.AddWithValue("@p0", ddlstudID.SelectedValue);
    
            var adapter = new OleDbDataAdapter(command);
            adapter.Fill(ds10);
        }
    
        ddlclassSelect.DataSource = ds10;
        ddlclassSelect.DataTextField = "class\_ID";
        ddlclassSelect.DataValueField = "class\_ID";
        ddlclassSelect.DataBind();
        ddlcla
    
    ASP.NET css help design sysadmin question

  • Mini-registration Check if Room is booked or open
    W WickedFooker

    I have been creating a smaller scale MUCH SIMPLIFIED version of a registration system that assumes classes are taught once a week. This system already checks if a teacher has taught 3 classes to not select him for further classes. But I need to make sure it also checks that the room is not already chosen for a class previous during the time it wants. What I have so far selects rooms and shows them in a drop down list, but I am able to make it show all room less everything chosen so far but it does not take into consideration the time and day of the week and so it is eliminating anything chosen, not just for the day of the week and the start_Hour and end_Hour times.

    // Populate Room and add Please Select
    // This shows ALL Rooms ---> string commandText1 = "SELECT * FROM tblRoom";\
    // Below shows ALL rooms minus any chosen before but does not consider day of the week (week_Day) or (start_Time and end_Time) of the class.
    string commandText1 = "SELECT * FROM tblRoom WHERE NOT EXISTS (SELECT * FROM tblClass WHERE tblRoom.room_Num = tblClass.room_Num)";

            var ds1 = new DataSet();
    
            using (var connection = new OleDbConnection(connectionString))
            using (var command = new OleDbCommand(commandText1, connection))
            {
                // OleDbCommand uses positional, rather than named, parameters.
                // The parameter name doesn't matter; only the position.
                command.Parameters.AddWithValue("@p0", ddlRoom.SelectedValue);
    
                var adapter = new OleDbDataAdapter(command);
                adapter.Fill(ds1);
            }
    
            ddlRoom.DataSource = ds1;
            ddlRoom.DataTextField = "room\_Num";
            ddlRoom.DataValueField = "room\_Num";
            ddlRoom.DataBind();
            ddlRoom.Items.Insert(0, new ListItem("Please Select", "0"));
            ddlRoom.Items.Insert(1, new ListItem("TBD", "TBD"));
        }
    
    }
    

    tblRoom consists of tblRoom.room_Num (Key) TextString with Room# tblClass consists of tblClass.room_Num (FK) TextString, CourseID (FK) from tblCourse, week_Day which is the Day Of the Week (Monday, Tueday, Wednesday, Thursday, Friday or Saturday). start_Hour and end_Hour for when the class begins and ends. What I am looking for is to improve the select command above so it can use week_Day = ? (ddlweekDay.SelectedValue) start_Hour (ddlstarthour.selectedvalue), end_Hour (ddlendHour.SelectedValue) OR to "r

    ASP.NET css question announcement code-review

  • Returning true/false in a boolean function
    W WickedFooker

    I am trying to say if a teacher is already teaching 3 classes flag it by returning a true if so, or a false if not. I have it counting the rows (or so I thought), but it is saying the way I did it is not correct. That Tables[0] is invalid.

    private bool ValidateTeacher(string TeacherID, String Semester)
    {
    // Populate Room and add Please Select
    string path = Server.MapPath("eAcademy_DB.mdb");
    string connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
    string commandText = "SELECT COUNT(*) FROM tblClass WHERE emp_ID=? and sem_Time=?";

        var ds6 = new DataSet();
    
        using (var connection = new OleDbConnection(connectionString))
        using (var command = new OleDbCommand(commandText, connection))
        {
            // OleDbCommand uses positional, rather than named, parameters.
            // The parameter name doesn't matter; only the position.
          
    
            var adapter = new OleDbDataAdapter(command);
            if (ds6.Tables\[0\].Rows.Count > 3)
            {
                return false;
            }
            else return true;
            
        }
    }
    
    ASP.NET sysadmin question

  • Web Services / Web References in ASP.NET using C#
    W WickedFooker

    Okay. I got it working 100%. I was totally over-thinking things. I made some minor changes to part of the code and took out the form submit junk I had. Thanks again for your help.

    ASP.NET csharp html asp-net wcf help

  • Web Services / Web References in ASP.NET using C#
    W WickedFooker

    Richard thanks for the insight. I cleaned up things a bit to this: clsWebServices.aspx.cs

    using System.Data.OleDb;
    using System.Data;
    using System.Web.Services;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    [WebService(Namespace = "http://localhost:51557/Week3Lab/clsWebServices.asmx/FindAddress")]
    public class clsWebServices : System.Web.Services.WebService {

    public clsWebServices () {
    
        //InitializeComponent();
        
    }
    
       \[WebMethod(Description = "This method call will get the LastName and return the Dataset.", EnableSession = false)\]  
        public dsAddress FindAddress(string LastName, string Path)
        {
            
            
            string connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path;
            string commandText = "select \* from tblAddressBook where LastName like "+LastName ;
    
    
            dsAddress DS = new dsAddress();
            using (var connection = new OleDbConnection(connectionString))
            using (var command = new OleDbCommand(commandText, connection))
            {
               
                var adapter = new OleDbDataAdapter(command);
                adapter.Fill(DS.tblAddressBook);
            }
    
            // Add your comments here
            return DS;
    
        }
    

    }

    frmAddressBook.aspx.cs

    protected void btnFindLastName_Click(object sender, EventArgs e)
    {
    lblMessage.Text = "";
    lblMessage.Text = txtFindLastName.Text;
    try
    {
    clsWebServices serviceObj = new clsWebServices();
    dsAddress dsFindLastName = new dsAddress();
    string TempPath = Server.MapPath("~/App_Data/AddressBook.mdb");

            dsFindLastName = serviceObj.FindAddress(txtFindLastName.Text.ToString(), TempPath);
    
            if (dsFindLastName.tblAddressBook.Rows.Count > 0)
            {
                DataRow r = dsFindLastName.tblAddressBook.Rows\[0\];
                txtFirstName.Text = r\["FirstName"\].ToString();
                txtLastName.Text = r\["LastName"\].ToString();
                txtEmail.Text = r\["Email"\].ToString();
                txtPhoneNumber.Text = r\["PhoneNumber"\].ToString();
            }
            else lblMessage.Text = "No records found!";
        }
        catch (Exception ex)
        {
            lblMessage.Text = lblMessage.Text + ex.Message;
        }
    }
    

    When I subm

    ASP.NET csharp html asp-net wcf help

  • Web Services / Web References in ASP.NET using C#
    W WickedFooker

    I have no idea what I am wrong. Needless to say it is giving me a compiler error "Error 1 'clsWebServices' does not contain a definition for 'FindAddress' and no extension method 'FindAddress' accepting a first argument of type 'clsWebServices' could be found (are you missing a using directive or an assembly reference?)" What do I need to do to make this Web Method / Web Reference work properly? This is for a local Access .mdb file that resides under app_Data. This is what I have under App_Code for clsWebSerices.cs:

    using Microsoft.VisualBasic;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Data.OleDb;
    using System.Web.Services;

    /// /// Summary description for clsWebServices
    ///

    public class clsWebServices : System.Web.Services.WebService {

    public clsWebServices () {
    
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
    public class Service1 : System.Web.Services.WebService
    {
        \[WebMethod\]  
        public dsAddress FindAddress(string LastName, string Path)
        {
            
            
            string connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path;
            string commandText = "select \* from tblAddressBook where LastName like '" + LastName + "'";
    
            dsAddress DS = default(dsAddress);
    
            using (var connection = new OleDbConnection(connectionString))
            using (var command = new OleDbCommand(commandText, connection))
            {
                // OleDbCommand uses positional, rather than named, parameters.
                // The parameter name doesn't matter; only the position.
                DS = new dsAddress();
                var adapter = new OleDbDataAdapter(command);
                adapter.Fill(DS);
            }
    
            // Add your comments here
            return DS;
    
        }
        
    }
    

    }

    And for clsWebServices.asmx:

    <%@ WebService Language="C#" CodeBehind="~/App_Code/clsWebServices.cs" Class="clsWebServices" %>

    frmAddressBook.aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmAddressBook.aspx.cs" Inherits="frmAddressBook" %>

    <html xmlns="http://www.w3.org/1999/xhtml"

    ASP.NET csharp html asp-net wcf help

  • Validation Question - Help
    W WickedFooker

    Okay so very easy to validate an email in ASP and also very easy to validate that someone enters between 6 and 30 characters but can someone help me in making sure that BOTH are checked in a Custom Validation perhaps. What I have for example:

    I am sure it is something simple but just need to know. Right now all it is doing is just checking that the email is valid, but if nothing is on the field it checks nothing.

    ASP.NET help tutorial question

  • Access Database, ASP/C# Drop Down List populating a Drop Down List
    W WickedFooker

    I just want to thank you for the help! This did the trick. I was able to populate the 2nd table with perhaps the smallest of changes.

    string commandText = "SELECT * FROM tblEmployee WHERE canTeach = " + ddlcourseType.SelectedValue;

    I removed the select on the bottom and instead put it in the page load since it is more needed for looks when the page loads. Thanks again for your help. I am certain I will be back for more :) REVISED: I see your warning about String concatenation. I will change it back. I went back to the way you originally posted it!

    ASP.NET csharp database sysadmin lounge

  • Access Database, ASP/C# Drop Down List populating a Drop Down List
    W WickedFooker

    Ok this has sort of been asked before but also somewhat differently here. I have a regular drop down (not connected to a database) that just has the topics of subjects. This is a sample of what I have:

                       Please Select
                       English
                       Math
                       Social Studies
                       Science
                       History
    

    I want to make it so that when it changes the next part will search and select teachers that teach that specific subject. I am using an Access Database for connection. I have pieced together some of what others did in an attempt to get it to work but no.

    protected void ddlcourseType_SelectedIndexChanged(object sender, EventArgs e)
    {
    OleDbConnection dbConn = null;
    OleDbCommand dbCmd;
    OleDbDataReader dr;
    String strConnection;
    String strSQL;
    string path = Server.MapPath("eAcademy_DB.mdb");

        string Teachable = Convert.ToString(ddlcourseType.SelectedValue);
        strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
        dbConn = new OleDbConnection(strConnection);
        dbConn.Open();
        strSQL = "select \* from tblEmployee where canTeach=" + Teachable;
    
        dbCmd = new OleDbCommand(strSQL, dbConn);
        DataSet ds = new DataSet();
                
        dbConn.Close();
        ddlTeacher.DataSource = ds;
        ddlTeacher.DataTextField = "emp\_ID";
        ddlTeacher.DataValueField = "emp\_ID";
        ddlTeacher.DataBind();
        ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
        if (ddlTeacher.SelectedValue == "0")
        {
            ddlTeacher.Items.Clear();
            ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
        }
    }
    

    I think what I really need to do is make a for loop and have it iterate for the amount of teachers that are in the list, and then have it populate the list, but not sure how exactly to do thi

    ASP.NET csharp database sysadmin lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups