Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

insert values in database table using stored procedure and asp.net this means:

i created 2 web pages here one page contain: name, email, password

2nd page contain: education, year

here these two web pages of name, email, password, education, year


these insert single table this is possible or not please reply what about or any examples
Posted

Means you want to insert values in single table using two web pages. IF like that means you have to call one stored Proceder for both two pages. Below is example link

Insert Data Using Stored Procedure in ASP.NET[^]
 
Share this answer
 
v2
Comments
member1431 10-Jul-14 4:19am    
yes i want two pages of values in single table please reply me mazharkhan123


please reply me
member1431 10-Jul-14 4:20am    
yes i want 2 web pages of values in single table please reply me mazharkhan123


please reply me
mazharkhan123 10-Jul-14 4:22am    
send me your table fields. Are you fresher or developer?
member1431 10-Jul-14 4:34am    
please check and reply me

web page1:
Design:
<form id="form1" runat="server">
<div>

<table class="style1">
<tr>
<td>
Name</td>
<td>
<asp:TextBox ID="TextBox1" runat="server">
</td>
</tr>
<tr>
<td>
Upload File</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr>
<td>
Password :</td>
<td>
<asp:TextBox ID="TextBox2" runat="server">
</td>
</tr>
<tr>
<td>
ConfirmPassword :</td>
<td>
<asp:TextBox ID="TextBox3" runat="server">
</td>
</tr>

<tr>
<td>
 </td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</td>
</tr>

</table>

</div>
</form>

web page2:
Design:
<form id="form1" runat="server">
<div>

<table class="style1">
<tr>
<td>
Education</td>
<td>
<asp:TextBox ID="TextBox1" runat="server">
</td>
</tr>
<tr>
<td>
Job Type</td>
<td>
<asp:TextBox ID="TextBox2" runat="server">
</td>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
</tr>
<tr>
<td>
 </td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click1"
Text="Submit" />
<asp:Label ID="Label1" runat="server" Text="Label">
</td>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
</tr>
</table>

</div>
</form>


source code:

protected void Button1_Click(object sender, EventArgs e)
{
int userId = 0;

string constr = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;

using(SqlConnection con=new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SPP_uploadfile"))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);

//string strdata = @"~\data\" + FileUpload1.FileName;
//FileUpload1.PostedFile.SaveAs(Server.MapPath(strdata));

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", TextBox1.Text);
cmd.Parameters.AddWithValue("@Uploadfile", FileUpload1.FileBytes);
cmd.Parameters.AddWithValue("@Password", TextBox2.Text);
cmd.Parameters.AddWithValue("@ConfirmPassword", TextBox3.Text);

cmd.Connection = con;
con.Open();
userId = Convert
Add this code into your web page two, similar add web page1 c sharp code. you will get result.

String ConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "AddUser";
cmd.Parameters.Add("@Education",SqlDbType.VarChar).Value = Textbox1.Text.Trim();
cmd.Parameters.Add("@Job_Type", SqlDbType.VarChar).Value = Textbox2.Text.Trim();

cmd.Connection = con;
try
{
con.Open();
cmd.ExecuteNonQuery();
lblMessage.Text = "Record inserted successfully";
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}


Write two stored procedure for understanding purpose, otherwise you will confused.

i am writing procedure for web page 2. you write similar two page1.
create procedure AddUser
(
@Location varchar(100),
@Job_type varchar(100)
)
as
begin

insert into user values(@Location,@Job_type)
end.
 
Share this answer
 
v3
Comments
mazharkhan123 10-Jul-14 5:19am    
Mark as solution accept. IF got result
mazharkhan123 10-Jul-14 5:21am    
If you not getting check below link but accept solution. Hope you will get from this link. thanks

http://aspdotnetcode.blogspot.in/2010/09/insert-record-in-database-using-stored.html
member1431 10-Jul-14 6:20am    
here am already created stored procedure
first web page insertion and second page updation of same table
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900