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
H

humayunlalzad

@humayunlalzad
About
Posts
85
Topics
25
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • User Control
    H humayunlalzad

    I did try the Masked the text box, with the

    MaskedTextBox.PromptChar = " "

    option but the problem was the two brackets in the text box for the phone area code( ) were too ugly and wrinkly. And also when you click on the text box the cursor is not inside the "( )" brackets it gets placed before the first bracket, which was kind of irritating. So I though let me try out the UserControl text box option. Which is working fine now.

    C# regex help

  • User Control
    H humayunlalzad

    I am creating a user control which will work as a Telephone number validator. I want that when Regex is not a match the Text property should not return any kind of string. Can someone help with the code, as with my code, the errorprovider is instantiated but it still continues and returns the invalid phone number

    public override string Text
    {
    get {
    string phone = textBox1.Text.Trim() + textBox2.Text.Trim() + textBox3.Text.Trim();
    if (!Regex.IsMatch(phone, @"^\d{9}$"))
    {
    errorProvider1.SetError(textBox3, "Please provide a valid phone number");
    errorProvider1.SetIconAlignment(textBox3, ErrorIconAlignment.MiddleRight);

                }
                
                return phone;
            }
            set {
                string phone;
                
                phone = value;
                textBox1.Text = phone.Substring(0, 3);
                textBox2.Text = phone.Substring(3, 3);
                textBox3.Text = phone.Substring(6);
            }
        }
    
    C# regex help

  • Textbox for phone number
    H humayunlalzad

    Thanks a lot That was so simple, that it got overlooked

    C# help hardware tutorial

  • Textbox for phone number
    H humayunlalzad

    The masked textbox did the trick, the only problem was that it shows those ugly looking lines

    (___)___-____

    is there a way to get rid of the lines and it just displays

    ( ) -

    but works the way the masked textbox worked. I tried providing my own mask as well, but the lines in the textbox will not go.

    C# help hardware tutorial

  • Textbox for phone number
    H humayunlalzad

    I found many which would format the phone number after it has been entered, but I could not find any where the bracket and the hyphen were already embedded in the textbox when it loads. If you can direct me to one it would be great.

    C# help hardware tutorial

  • Textbox for phone number
    H humayunlalzad

    I want a textbox for a phone number. I want the text box to have this format

    ( ) -

    embedded inside it. When some one inputs the phone number the first three numbers (area code) should automatically fit in the bracket area and the next three before the hyphen and the last four after the hyphen (without the user having to type the bracket or the hyphen. I have no idea how to approach the problem. Pl help

    C# help hardware tutorial

  • Copying table
    H humayunlalzad

    Thanks a lot that did the trick. That was what I was looking for.

    Select * into

    C# database tutorial

  • Copying table
    H humayunlalzad

    I was trying something like this

    SqlDataAdapter da;
    DataSet ds = new DataSet();

            string conString = @"server = .\\sqlexpress;
                                integrated security = true;
                                database = northwind";
            da = new SqlDataAdapter("select \* from employees", conString);
            da.Fill(ds);
            DataTable table = ds.Tables\[0\];
    
            string conString2 = @"server = .\\sqlexpress;
                                integrated security = true;
                                database = ABZ";
            string commandString = "Create table Employees ( ";
            SqlConnection con = new SqlConnection(conString2);
            DataTable tab = new DataTable("Employees");
            foreach (DataColumn  column in table.Columns )
            {
              
                commandString = commandString + column.ColumnName +" nvarchar (50), "  ;
               
            }
            
            commandString = commandString + ")";
    
            SqlCommand cmd = new SqlCommand(commandString, con);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Table Created");
    

    But the prob was I was getting a -1 value for column.MaxLength when I was trying this

    foreach (DataColumn column in table.Columns )
    {

                commandString = commandString + column.ColumnName +" nvarchar (" + column.MaxLength + "), "  ;
               
            }
    

    But how do you suggest I use the Select statement?

    C# database tutorial

  • Copying table
    H humayunlalzad

    Thanks in advance, as that was the second part of my problem, to copy the data once the table has been copied. The first one was to copy the table itself, still looking for an answer.

    C# database tutorial

  • Copying table
    H humayunlalzad

    I am trying something like this, but its not very accurate

    SqlDataAdapter da;
    DataSet ds = new DataSet();

            string conString = @"server = .\\sqlexpress;
                                integrated security = true;
                                database = northwind";
            da = new SqlDataAdapter("select \* from employees", conString);
            da.Fill(ds);
            DataTable table = ds.Tables\[0\];
    
            string conString2 = @"server = .\\sqlexpress;
                                integrated security = true;
                                database = ABZ";
            string commandString = "Create table Employees ( ";
            SqlConnection con = new SqlConnection(conString2);
            DataTable tab = new DataTable("Employees");
            foreach (DataColumn  column in table.Columns )
            {
              
                commandString = commandString + column.ColumnName + " " + column.DataType + " " + "nvarchar (50), "  ;
               
            }
    

    I can make a switch statement for the data type. But the maximum size of the data always shows up as -1

    C# database tutorial

  • Copying table
    H humayunlalzad

    I have a created a database by the name of ABC. I want to copy the employees table from the northwind database to my database. Whats the best way to do it. Can someone direct me to a useful link or let me know how to do it dynamically.

    C# database tutorial

  • Sqlparameter
    H humayunlalzad

    Ok I get it now. But is there any other way of doing it?

    C# help

  • Sqlparameter
    H humayunlalzad

    The following does not work

       cmd = con.CreateCommand();
       cmd.CommandText = @"select \* from tblcustomer where @column = @value";
       cmd.Parameters.Add("@column", SqlDbType.NVarChar , 50);
       cmd.Parameters.Add("@value", SqlDbType.NVarChar , 100);
       cmd.Parameters\["@column"\].Value = comboBox1.SelectedItem.ToString();
       cmd.Parameters\["@value"\].Value = txtSearch.Text;
    

    But this workds

    cmd = con.CreateCommand();
    cmd.CommandText = @"select * from tblcustomer where " + comboBox1.SelectedItem.ToString() + " = @value";
    //cmd.Parameters.Add("@column", SqlDbType.NVarChar , 50);
    cmd.Parameters.Add("@value", SqlDbType.NVarChar , 100);
    //cmd.Parameters["@column"].Value = comboBox1.SelectedItem.ToString();
    cmd.Parameters["@value"].Value = txtSearch.Text;

    Can someone tell me whats the problem with the first code snippet

    C# help

  • Connection string
    H humayunlalzad

    @"
    server = .\sqlexpress;
    integrated security = true;
    database = northwind;
    user instance = true";

    I am sorry I should have mentioned before hand, that even the above string with "user instance = true" added is not working

    C# database sql-server sysadmin security

  • Connection string
    H humayunlalzad

    connectionString1 = @"
    server = .\sqlexpress;
    integrated security = true;
    database = C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\NORTHWND.MDF;
    user instance = true";

    connectionString2 = @"
    server = .\sqlexpress;
    integrated security = true;
    database = northwind";

    connectionString1 is working fine and connectionString2 is giving the message "Cannot open database northiwnd. login failed for user XYZ". Can someone tell me whats the difference

    C# database sql-server sysadmin security

  • Programmatically creating button
    H humayunlalzad

    When recreating the controls in Page_PreInit, the line Table1.Controls.Add(row); gives an error.

    ASP.NET

  • Programmatically creating button
    H humayunlalzad

    I am creating a button, a textbox and a label control, when a linkbutton is clicked. I have assigned an event handler to the button, but when the button is clicked nothing happens and even the previous controls created, disappear protected void LinkButton2_Click(object sender, EventArgs e) { TableRow row = new TableRow(); TableCell cell1 = new TableCell(); txt = new TextBox(); txt.Rows = 2; txt.Height = 40; txt.Width = 200; cell1.Controls.Add(txt); row.Controls.Add(cell1); btn = new Button(); btn.Text = "Submit"; btn.Click += new EventHandler(btn_Click); TableCell cell2 = new TableCell(); cell2.Controls.Add(btn); row.Controls.Add(cell2); lbl1 = new Label(); lbl1.Text = "Your Comments"; TableCell cell3 = new TableCell(); cell3.Controls.Add(lbl1); row.Controls.Add(cell3); Table1.Controls.Add(row); } void btn_Click(object sender, EventArgs e) { //Does not reach here }

    ASP.NET

  • xml file vs .config
    H humayunlalzad

    I have made a simple game and for the name and score/top score, number of turns etc. of the players, I have used an xml file of my own. Would I have any reason to store all that information in the .config file, making my own sections or key value pairs in appSettings. Or is the .config file is only useful when we are talking configuration? I have read many articles on codeproject/msdn etc., but still confused.

    C# visual-studio game-dev xml question workspace

  • string versus String !
    H humayunlalzad

    Why is the ref keyword added to String in this example. Isn't string a reference type already? I thought ref is only to make value types behave like reference types.

    C# question tutorial

  • Sleek looking window application
    H humayunlalzad

    Thanx I will try WPF

    C# design question
  • Login

  • Don't have an account? Register

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