- Joined
- Dec 12, 2014
- Posts
- 1,177
- Reaction
- 6,636
- Points
- 1,208
C#:
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PaboraandRodoy
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=BRYLLE\\BRYLLEZXRODOY;Initial Catalog=rodoytbl;User ID=sa;Password=***********");
con.Open();
SqlCommand comm = new SqlCommand("Insert into tblrodoy values('" + int.Parse(TextBox3.Text) + "', '" + TextBox4.Text + "', '" + TextBox5.Text + "', '" + TextBox6.Text + "', '" + TextBox7.Text + "',)", con);
comm.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this,this.GetType(),"script","Alert('Successfully Inserted'); ", true );
}
}
}
C#:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PaboraandRodoy._Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div style="font-size:x-large" align="center"> CVSU STUDENT INFO </div>
<br />
<table class="nav-justified">
<tr>
<td style="width: 166px"> </td>
<td style="width: 169px">Student ID</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" Font-Size="Medium" Width="197px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 166px"> </td>
<td style="width: 169px">Student Name</td>
<td>
<asp:TextBox ID="TextBox4" runat="server" Font-Size="Medium" Width="197px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 166px; height: 26px;"></td>
<td style="width: 169px; height: 26px;">Course</td>
<td style="height: 26px">
<asp:TextBox ID="TextBox5" runat="server" Font-Size="Medium" Width="197px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 166px"> </td>
<td style="width: 169px">Section</td>
<td>
<asp:TextBox ID="TextBox6" runat="server" Font-Size="Medium" Width="197px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 166px; height: 26px;"></td>
<td style="width: 169px; height: 26px;">Subject</td>
<td style="height: 26px">
<asp:TextBox ID="TextBox7" runat="server" Font-Size="Medium" Width="197px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 166px; height: 28px;"></td>
<td style="width: 169px; height: 28px;"></td>
<td style="height: 28px">
<asp:Button ID="Button1" runat="server" BackColor="#FFCC66" Font-Bold="True" ForeColor="Black" Text="Insert" Width="61px" OnClick="Button1_Click" />
</td>
</tr>
<tr>
<td style="width: 166px; height: 28px;"></td>
<td style="width: 169px; height: 28px;"></td>
<td style="height: 28px">
</td>
</tr>
<tr>
<td style="width: 166px; height: 28px;"> </td>
<td style="width: 169px; height: 28px;"> </td>
<td style="height: 28px">
<asp:GridView ID="GridView1" runat="server" Width="596px">
</asp:GridView>
</td>
</tr>
</table>
<td> </td>
</asp:Content>
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.