我有一个createuserwizard(cuw)控件,我想添加更多字段(自定义)。我需要将此信息存储在名为“UserProfiles”的数据库中。我添加了一个fileupload控件来存储图像(头像),问题出在这里。当我刷新数据库时(在我填充cuw控件之后),我可以看到所有列的新数据,除了图像列。我的问题是在代码背后。这是我的代码:
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.Web.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
CreateUserProfile(CreateUserWizard1.UserName, txtFirstName.Text, txtLastName.Text, CreateUserWizard1.Email, CreateUserWizard1.Password, imgUpload.FileName);
}
private void CreateUserProfile(string UserName, string Gender, string LookingFor, string Email, string Password, string Image)
{
string conString = WebConfigurationManager.ConnectionStrings["UserProfiles"].ConnectionString;
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("INSERT UserProfiles (UserName,Gender,LookingFor,EMail,Password,Image) VALUES (@UserName,@Gender,@LookingFor,@EMail,@Password,@Image)", con);
cmd.Parameters.AddWithValue("@UserName", UserName);
cmd.Parameters.AddWithValue("@Gender", Gender);
cmd.Parameters.AddWithValue("@LookingFor", LookingFor);
cmd.Parameters.AddWithValue("@EMail", Email);
cmd.Parameters.AddWithValue("@Password", Password);
cmd.Parameters.AddWithValue("@Image", Image);
using (con)
{
con.Open();
cmd.ExecuteNonQuery();
}
}
}
我是初学者。在此先感谢您的帮助。