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.Configuration; using System.Data; public partial class Default7 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (!FileUpload1.HasFile) //Validation { Response.Write("No file Selected"); return; } else { string filename = FileUpload1.PostedFile.FileName; //convert the image into the byte byte[] imageByte = System.IO.File.ReadAllBytes(filename); //Insert the Data in the Table using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = ConfigurationManager.ConnectionStrings["lateefconnectionstring"].ToString(); connection.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; string commandText = "Insert into users values (@Surname,@Lastame,@username,@Phone,@image,getdate,@Department())"; cmd.CommandText = commandText; cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@Surname", SqlDbType.VarChar); cmd.Parameters["@Surname"].Value = TxtSurname.Text; cmd.Parameters.Add("@Lastame", SqlDbType.VarChar); cmd.Parameters["@Lastame"].Value = TxtLastName.Text; cmd.Parameters.Add("@username", SqlDbType.VarChar); cmd.Parameters["@username"].Value = TxtUsername.Text; cmd.Parameters.Add("@Phone", SqlDbType.VarChar); cmd.Parameters["@Phone"].Value = TxtPhone.Text; cmd.Parameters.Add("@image", SqlDbType.VarBinary); cmd.Parameters["@image"].Value = imageByte; cmd.Parameters.Add("@Department", SqlDbType.VarChar); cmd.Parameters["@Department"].Value = TxtDpt.Text; cmd.ExecuteNonQuery(); cmd.Dispose(); connection.Close(); Response.Write("Data has been Added"); } } } }
string commandText = "Insert into users values (@Surname,@Lastame,@username,@Phone,@image,getdate,@Department())";
string commandText = "Insert into users values (@Surname,@Lastame,@username,@Phone,@image,getdate,@Department)";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)