The following code snippet can help solve the problem that we are discussing here. Please ignore this if it is not relevant to this topic.
, . , , .
"" :
using System.Data;
using System.Data.Sql
using System.Data.SqlClient;
using System.Web;
using System.Web.Services;
public class FileUploader: System.Web.Services.WebService {
SqlConnection myConnection = new SqlConnection("Data Source=server name ;Initial Catalog=database name; User ID=username; Password='password';");
SqlCommand myCommand = new SqlCommand();
string queryString = "";
public string UploadFile(byte[] f, string fileName)
{
string nm = data[0];
string sn =data[1];
string bn =data[2];
string st = data[3];
byte img = Convert.Tobyte(img);
myConnection.Open();
queryString = "INSERT INTO tablename(Name,SchemeName,BeneficiarName,Status,Photo)"
+ "VALUES('" + nm + "','" + sn + "','"+ bn +"','" + st + "',@img,')";
myCommand.Parameters.AddWithValue("@img",f);
myCommand.Connection = myConnection;
myCommand.CommandType = CommandType.Text; myCommand.CommandText = queryString; int res = myCommand.ExecuteNonQuery(); myConnection.Close();
if (res > 0)
{
strres = "File Uploaded successfully"; }
else
{
strres = "File not uploaded";
}
return strres;
}
Visual Studio.Net 2005
.Net Framework 2.0
MS SQL Server 2000 MS SQL Server 2005.