TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ankit Kumar
NA
159
48.3k
Data Insertion in data base
Oct 8 2015 3:49 AM
Hey guys,
can any one help me please. i am facing error while inserting data in database using asp .net.
Here is the complete code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
SqlConnection con = new SqlConnection("");
protected void Button1_Click(object sender, EventArgs e)
{
string connection = "Data Source=127.0.0.1; Initial Catalog=test; Integrated Security=true";
con.ConnectionString=connection;
try
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into studentfeedback values @name, @email, @contact, @company",con);
cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = TextBox1.Text;
cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = TextBox1.Text;
cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = TextBox1.Text;
cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = TextBox1.Text;
if(Convert.ToBoolean(cmd.ExecuteNonQuery()))
{
Response.Write("<script>alert('Data Successfully Inserted')</script>");
}
}
catch (Exception exp)
{
Response.Write("<script>alert('" + exp.Message + "')</script>");
}
finally
{
con.Close();
}
}
}
Reply
Answers (
5
)
uploading csv file to mysql
file downloader and save them in user defined folder