Can't Insert into DB

3 posts, 0 answers
  1. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 17 Apr 2013 Link to this post

    <table style="width:100%;">
            <tr>
                <td class="style9">
                    Basic information
                </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style4">
                     </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style4">
                    Name :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox1" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                    Departement :</td>
                <td>
                    <telerik:RadComboBox ID="RadComboBox2" Runat="server"
                        DataSourceID="SqlDataSource2" DataTextField="U_Dep" Width="200px">
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td class="style4">
                    Title :</td>
                <td class="style7">
                    <telerik:RadComboBox ID="RadComboBox1" Runat="server"
                        DataSourceID="SqlDataSource1" DataTextField="U_Title" DataValueField="U_Title"
                        Width="230px">
                    </telerik:RadComboBox>
                </td>
                <td class="style6">
                    Internal Mail :
                </td>
                <td>
                    <telerik:RadTextBox ID="RadTextBox4" Runat="server">
                    </telerik:RadTextBox>
                </td>
            </tr>
            <tr>
                <td class="style4">
                    Manager Name :</td>
                <td class="style7">
                    <telerik:RadComboBox ID="RadComboBox3" Runat="server"
                        DataSourceID="SqlDataSource4" DataTextField="U_Manger_Name"
                        DataValueField="U_Manger_Name">
                    </telerik:RadComboBox>
                </td>
                <td class="style6">
                    Manager Internal Mail :</td>
                <td>
                    <telerik:RadTextBox ID="RadTextBox13" Runat="server">
                    </telerik:RadTextBox>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    System Password  :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox2" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                    Region :</td>
                <td>
                    <telerik:RadComboBox ID="RadComboBox4" Runat="server"
                        DataSourceID="SqlDataSource3" DataTextField="U_Region"
                        DataValueField="U_Region">
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Work Mobile Number :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox3" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                     </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style8">
                    Personal Information
                </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                     </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                    National ID Number :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox6" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                    National ID Expire Date :</td>
                <td>
                    <telerik:RadDatePicker ID="RadDatePicker1" Runat="server">
                    </telerik:RadDatePicker>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Address :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox7" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                    Sex :</td>
                <td>
                    <telerik:RadComboBox ID="RadComboBox6" Runat="server">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Text="Male" Value="Male" />
                            <telerik:RadComboBoxItem runat="server" Text="Female" Value="Female" />
                        </Items>
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Marital Status :</td>
                <td class="style7">
                    <telerik:RadComboBox ID="RadComboBox5" Runat="server">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Text="Single" Value="Single" />
                            <telerik:RadComboBoxItem runat="server" Text="Married" Value="Married" />
                            <telerik:RadComboBoxItem runat="server" Text="Divorced" Value="Divorced" />
                            <telerik:RadComboBoxItem runat="server" Text="Widowed" Value="Widowed" />
                        </Items>
                    </telerik:RadComboBox>
                </td>
                <td class="style6">
                    Private Mobile Number :</td>
                <td>
                    <telerik:RadTextBox ID="RadTextBox8" Runat="server">
                    </telerik:RadTextBox>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Picture :
                </td>
                <td class="style7">
                    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server">
                    </telerik:RadAsyncUpload>
                </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style8">
                     </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style8">
                    HR Information :</td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                     </td>
                <td class="style7">
                     </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                    Start Date :</td>
                <td class="style7">
                    <telerik:RadDatePicker ID="RadDatePicker2" Runat="server">
                    </telerik:RadDatePicker>
                </td>
                <td class="style6">
                    Status :</td>
                <td>
                    <telerik:RadComboBox ID="RadComboBox7" Runat="server">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Text="Normal user"
                                Value="Normal user" />
                            <telerik:RadComboBoxItem runat="server" Text="Admin" Value="Admin" />
                        </Items>
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Insurance Number :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox9" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                    Insurance Date :</td>
                <td>
                    <telerik:RadDatePicker ID="RadDatePicker3" Runat="server">
                    </telerik:RadDatePicker>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Annual Vacation Balance :</td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox10" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                    Incident Vacation Balance :</td>
                <td>
                    <telerik:RadTextBox ID="RadTextBox12" Runat="server">
                    </telerik:RadTextBox>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    Day Off :</td>
                <td class="style7">
                    <telerik:RadComboBox ID="RadComboBox8" Runat="server">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Text="Saturday" Value="Saturday" />
                            <telerik:RadComboBoxItem runat="server" Text="Sunday" Value="Sunday" />
                            <telerik:RadComboBoxItem runat="server" Text="Monday" Value="Monday" />
                            <telerik:RadComboBoxItem runat="server" Text="Tuesday" Value="Tuesday" />
                            <telerik:RadComboBoxItem runat="server" Text="Wednesday" Value="Wednesday" />
                            <telerik:RadComboBoxItem runat="server" Text="Thursday" Value="Thursday" />
                            <telerik:RadComboBoxItem runat="server" Text="Friday" Value="Friday" />
                        </Items>
                    </telerik:RadComboBox>
                </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                    Qualifications :
                </td>
                <td class="style7">
                    <telerik:RadTextBox ID="RadTextBox11" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td class="style6">
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style5">
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="SELECT DISTINCT [U_Title] FROM [Users] ORDER BY [U_Title]">
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="SELECT DISTINCT [U_Dep] FROM [Users] ORDER BY [U_Dep]">
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="SqlDataSource3" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="SELECT DISTINCT [U_Region] FROM [Users] ORDER BY [U_Region]">
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="SELECT DISTINCT [U_Manger_Name] FROM [Users] ORDER BY [U_Manger_Name]">
                    </asp:SqlDataSource>
                </td>
                <td class="style7">
                                                                     
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click1"
                        style="width: 56px" Text="Button" />
                </td>
                <td class="style6">
                    <telerik:RadTextBox ID="RadTextBox14" Runat="server">
                    </telerik:RadTextBox>
                </td>
                <td>
                     </td>
            </tr>
        </table>
    const int MaxTotalBytes = 1048576;
    int totalBytes;
    public bool? IsRadAsyncValid
    {
        get
        {
            if (Session["IsRadAsyncValid"] == null)
            {
                Session["IsRadAsyncValid"] = true;
            }
            return Convert.ToBoolean(Session["IsRadAsyncValid"].ToString());
        }
        set
        {
            Session["IsRadAsyncValid"] = value;
        }
    }
    public static string ConnectionString
    {
        get
        {
            return ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        }
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        IsRadAsyncValid = null;
    }
     
     
    protected void Button1_Click1(object sender, EventArgs e)
    {
     
        if (!IsRadAsyncValid.Value)
        {
            Response.Write("The length of the uploaded file must be less than 1 MB");
            return;
        }
     
     
     
     
        
        
        
     
     
        using (SqlConnection conn = new SqlConnection(ConnectionString))
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO [Users] ([U_Name], [U_Dep], [U_Title], [U_Internal_Mail], [U_Password], [U_Region], [U_Manger_Mail], [U_Manger_Name], [U_Status], [U_Week_End], [U_Balance], [U_Incednt], [Image], [Personal_ID], [ID_Expire_Date], [Sex], [Insurance_Number], [Insurance_Date], [Address], [Marital_Status], [Qualifications], [Work_Mobile_Number], [Private_Mobile_Number], [U_Start_Date]) VALUES (@U_Name, @U_Dep, @U_Title, @U_Internal_Mail, @U_Password, @U_Region, @U_Manger_Mail, @U_Manger_Name, @U_Status, @U_Week_End, @U_Balance, @U_Incednt, @Image, @Personal_ID, @ID_Expire_Date, @Sex, @Insurance_Number, @Insurance_Date, @Address, @Marital_Status, @Qualifications, @Work_Mobile_Number, @Private_Mobile_Number, @U_Start_Date)", conn);
     
            cmd.Parameters.AddWithValue("@U_Name", RadTextBox1.Text);
            cmd.Parameters.AddWithValue("@U_Dep", RadComboBox2.Text);
            cmd.Parameters.AddWithValue("@U_Title", RadComboBox1.Text);
            cmd.Parameters.AddWithValue("@U_Internal_Mail",RadTextBox4.Text );
            cmd.Parameters.AddWithValue("@U_Password",RadTextBox2.Text);
            cmd.Parameters.AddWithValue("@U_Region",RadComboBox4.Text );
            cmd.Parameters.AddWithValue("@U_Manger_Mail",RadTextBox13.Text );
            cmd.Parameters.AddWithValue("@U_Manger_Name",RadComboBox3.Text );
            cmd.Parameters.AddWithValue("@U_Status",RadComboBox7.Text );
            cmd.Parameters.AddWithValue("@U_Week_End", RadComboBox8.Text);
            cmd.Parameters.AddWithValue("@U_Balance",RadTextBox10.Text);
            cmd.Parameters.AddWithValue("@U_Incednt", RadTextBox12.Text);
            cmd.Parameters.AddWithValue("@Personal_ID", RadTextBox6.Text);
            cmd.Parameters.AddWithValue("@ID_Expire_Date", RadDatePicker1.SelectedDate);
            cmd.Parameters.AddWithValue("@Sex", RadComboBox6.Text);
            cmd.Parameters.AddWithValue("@Insurance_Number",RadTextBox9.Text);
            cmd.Parameters.AddWithValue("@Insurance_Date", RadDatePicker3.SelectedDate);
            cmd.Parameters.AddWithValue("@Address", RadTextBox7.Text);
            cmd.Parameters.AddWithValue("@Marital_Status", RadComboBox5.Text);
            cmd.Parameters.AddWithValue("@Qualifications", RadTextBox11.Text);
            cmd.Parameters.AddWithValue("@Work_Mobile_Number",RadTextBox3.Text);
            cmd.Parameters.AddWithValue("@Private_Mobile_Number",RadTextBox8.Text);
            cmd.Parameters.AddWithValue("@U_Start_Date", RadDatePicker2.SelectedDate);
            cmd.Parameters.AddWithValue("@Image", RadAsyncUpload1);
     
            cmd.ExecuteScalar();
     
        }
    }
  2. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 17 Apr 2013 Link to this post

    i need help to insert the data and the image in the database plllllz
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 22 Apr 2013 Link to this post

    Hi,

    I do not see the Grid that you are using, however, you could check this online demo application which demonstrates similar scenario like yours.

    Regards,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top