how to insert and retrieve video file into sql server database table.
hi ..........
I am developing 1 web application in asp.net using c#.net.
i am taken 3 classes like 1 is properties for all fields and 2 nd one is to sending parameter to frontend page(storedprocedure). and another is datahelper class.
Like below
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the below is only for fields
class properties:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Summary description for ClsInsertCompanyProfile
/// </summary>
public class ClsProperties
{
public ClsProperties()
{
//
// TODO: Add constructor logic here
//
}
//properties of ClsInsertCompanyprofile
string cmpname,newcmpname, cmpwebsite, cmpaddress, exicutivename, exicutiveemailid, phoneno, location, qualification, skillsets, jobdescription, desiredcandidateprofile, cmpprofile,status;
int noofemployees, experiance;
static byte[] image = new byte[4];
string dateofestablished, posteddate;
public string CmpName
{
set { cmpname = value; }
get { return cmpname; }
}
public string NewCmpName
{
set { newcmpname = value; }
get { return newcmpname; }
}
public string CmpWebsite
{
set { cmpwebsite = value; }
get { return cmpwebsite; }
}
public string CmpAddress
{
set { cmpaddress = value; }
get { return cmpaddress; }
}
public string ExicutiveName
{
set { exicutivename = value; }
get { return exicutivename; }
}
public string ExicutiveEmailid
{
set { exicutiveemailid = value; }
get { return exicutiveemailid; }
}
public string PhoneNumber
{
set { phoneno = value; }
get { return phoneno; }
}
public string Location
{
set { location = value; }
get { return location; }
}
public string Qualification
{
set { qualification = value; }
get { return qualification; }
}
public string SkillSets
{
set { skillsets = value; }
get { return skillsets; }
}
public string JobDescription
{
set { jobdescription = value; }
get { return jobdescription; }
}
public string DesiredCandidateProfile
{
set { desiredcandidateprofile = value; }
get { return desiredcandidateprofile; }
}
public string CmpProfile
{
set { cmpprofile = value; }
get { return cmpprofile; }
}
public string Status
{
set { status = value; }
get { return status; }
}
public string DateOfEstablished
{
set { dateofestablished = value; }
get { return dateofestablished; }
}
public string PostedDate
{
set { posteddate = value; }
get { return posteddate; }
}
public int NoOfEmployees
{
set { noofemployees = value; }
get { return noofemployees; }
}
public int Experiance
{
set { experiance = value; }
get { return experiance; }
}
public byte[] Images
{
set { image = value; }
get { return image; }
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
this below is only for send parameters to storedprocedure
i have give 1 small code
sendparameters:::using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Summary description for ClsInsertCompanyprofile
/// </summary>
public class ClsInsertCompanyprofile
{
ClsProperties objprop = new ClsProperties();
clsDataHelper dh = new clsDataHelper();
public int Insertcompanyprofile(ClsProperties objpr,out string msg)
{
try
{
SqlParameter[] p = new SqlParameter[19];
p[0] = new SqlParameter("@cmpname", objpr.CmpName);
p[1] = new SqlParameter("@cmpwebsite", objpr.CmpWebsite);
p[2] = new SqlParameter("@dateofcmpestablished", objpr.DateOfEstablished);
p[3] = new SqlParameter("@noofemployees", objpr.NoOfEmployees);
p[4] = new SqlParameter("@cmpaddress", objpr.CmpAddress);
p[5] = new SqlParameter("@exicutivename", objpr.ExicutiveName);
p[6] = new SqlParameter("@exicutiveemailid", objpr.ExicutiveEmailid);
p[7] = new SqlParameter("@phoneno", objpr.PhoneNumber);
p[8] = new SqlParameter("@experiance", objpr.Experiance);
p[9] = new SqlParameter("@location", objpr.Location);
p[10] = new SqlParameter("@qualification", objpr.Qualification);
p[11] = new SqlParameter("@skillsets", objpr.SkillSets);
p[12] = new SqlParameter("@jobdescription", objpr.JobDescription);
p[13] = new SqlParameter("@desiredcandidateprofile", objpr.DesiredCandidateProfile);
p[14] = new SqlParameter("@cmpprofile", objpr.CmpProfile);
p[15] = new SqlParameter("@posteddate", objpr.PostedDate);
p[16] = new SqlParameter("@status", objpr.Status);
p[17] = new SqlParameter("@cmpimage", objpr.Images);
p[18] = new SqlParameter("@msg", SqlDbType.NVarChar, 50);
p[18].Direction = ParameterDirection.Output;
int res = dh.ExecuteNonQuery("sp_insertcompanyprofile", p);
msg = p[18].Value.ToString();
return res;
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
below is for datahelper class
DataHelper::::using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// Summary description for clsDataHelper
/// </summary>
public class clsDataHelper
{
//public clsDataHelper()
//{
// //
// // TODO: Add constructor logic here
// //
//}
SqlConnection con;
SqlCommand cmd;
DataSet ds;
SqlDataAdapter da;
public clsDataHelper()
{
//
// TODO: Add constructor logic here
//
}
//METHOD TO CREATE CONNECTION
public void GetConnection()
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["SAS"].ConnectionString);
}
//METHOD TO CALL THE EXECUTENONQUERY METHOD
public int ExecuteNonQuery(string commandText, SqlParameter[] parameters)
{
try
{
GetConnection();
cmd = new SqlCommand(commandText, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
foreach (SqlParameter p in parameters)
{
cmd.Parameters.Add(p);
}
con.Open();
return cmd.ExecuteNonQuery();
}
catch (SqlException)
{
throw;
}
finally
{
con.Close();
}
}
//METHOD TO CALL THE EXECUTESCALAR METHOD
public int ExecuteScalar(string commandText, SqlParameter[] parameters)
{
try
{
GetConnection();
cmd = new SqlCommand(commandText, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
foreach (SqlParameter p in parameters)
{
cmd.Parameters.Add(p);
}
con.Open();
return Convert.ToInt32(cmd.ExecuteScalar());
}
catch (SqlException)
{
throw;
}
finally
{
con.Close();
}
}
//METHOD TO CALL THE EXECUTE DATASET METHOD
public DataSet ExecuteDataSet(string commandText, SqlParameter[] parameters)
{
// try
// {
GetConnection();
cmd = new SqlCommand(commandText, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
foreach (SqlParameter p in parameters)
{
cmd.Parameters.Add(p);
}
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
// }
//catch (SqlException)
// {
// throw;
//}
}
public DataSet ExecuteDataSet(string commandText)
{
try
{
GetConnection();
cmd = new SqlCommand(commandText, con);
cmd.CommandType = CommandType.StoredProcedure;
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
}
catch (SqlException)
{
throw;
}
}
-------------------------------------------------------------------------------------------------------------------------------------------
Is this process correct?
and i got one problem is that to insert and retrieve an image and video into database table.
please......please.........please....... send me code like abow process.
thanq.....