Picture upload part of the database (automatically generate the sketch)

Source: Internet
Author: User
Upload | data | database public int Fepicdataset (string strpictitle, String strpicdate, string strpicname, int intpictype, string str Picintro, string strthumbnail, int opid)
{

String Strpictitle,
String Strpicdate,
String Strpicname,
int Intpictype,
String Strpicintro,
String Strpicname,
String Strthumbnail,
int Opid
SqlConnection myconnection = new SqlConnection (configurationsettings.appsettings["ConnectionString"]);
SqlCommand mycommand = new SqlCommand ("Mag_fepicdataset", MyConnection);
Mark the Command as a sproc
myCommand.CommandType = CommandType.StoredProcedure;

Add Parameters to SPROC
SqlParameter Parameteruserid = new SqlParameter ("@opID", SqlDbType.Int);
Parameteruserid.value = Opid;
MYCOMMAND.PARAMETERS.ADD (Parameteruserid);

SqlParameter parameterpictitle = new SqlParameter ("@picTitle", SqlDbType.Char, 30);
Parameterpictitle.value = Strpictitle;
MYCOMMAND.PARAMETERS.ADD (Parameterpictitle);

SqlParameter parameterpicdate = new SqlParameter ("@picDate", SqlDbType.Char, 10);
Parameterpicdate.value = strpicdate;
MYCOMMAND.PARAMETERS.ADD (parameterpicdate);

SqlParameter parameterpicname = new SqlParameter ("@picName", SqlDbType.Char, 50);
Parameterpicname.value = Strpicname;
MYCOMMAND.PARAMETERS.ADD (Parameterpicname);

SqlParameter parameterpictype = new SqlParameter ("@picType", SqlDbType.Int);
Parameterpictype.value = Intpictype;
MYCOMMAND.PARAMETERS.ADD (Parameterpictype);

SqlParameter Parameterpicintro = new SqlParameter ("@picIntro", SqlDbType.Char, 255);
Parameterpicintro.value = Strpicintro;
MYCOMMAND.PARAMETERS.ADD (Parameterpicintro);

SqlParameter parameterthumbnail = new SqlParameter ("@thumbnail", SqlDbType.Char, 50);
Parameterthumbnail.value = Strthumbnail;
MYCOMMAND.PARAMETERS.ADD (Parameterthumbnail);

SqlParameter parameterhostaddress = new SqlParameter ("@opIP", SqlDbType.Char, 15);
Parameterhostaddress.value = Context.Request.UserHostAddress;
MYCOMMAND.PARAMETERS.ADD (parameterhostaddress);

SqlParameter Parameterrid = new SqlParameter ("@returnID", SqlDbType.Int);
Parameterreturnuserid.value =-1;
Parameterrid.direction = ParameterDirection.Output;
MYCOMMAND.PARAMETERS.ADD (Parameterrid);



Execute the command in a try/catch to catch duplicate username errors
Try
{
The Open the connection and execute the Command
Myconnection.open ();
Mycommand.executenonquery ();
}
Catch
{

Failed to create a new user
return-1;
}
Finally
{

Close the Connection
if (myConnection.State = = ConnectionState.Open)
Myconnection.close ();
}

return 1;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.