为什么mysql不处理空格,我该如何对抗?
如果我在db中有一个带有空格的路径名,那么它会将%放在那个不起作用的空间的位置?
public partial class UserProfile : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite; User=root; Password=commando;");
cn.Open();
OdbcCommand cmd = new OdbcCommand("SELECT User.FirstName, User.SecondName, User.Aboutme, User.DOB, Pictures.picturepath FROM User LEFT JOIN Pictures ON User.UserID = Pictures.UserID WHERE User.UserID=1", cn);
OdbcDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Name.Text = String.Format("{0} {1}", reader.GetString(0), reader.GetString(1));
Aboutme.Text = String.Format("{0}", reader.GetString(2));
Age.Text = String.Format("{0}", reader.GetString(3));
Image1.ImageUrl = String.Format("{0}", reader.GetString(4));
}
}
}
输出:
<div class="image">
<a href="#"></a>
<img style="border-width: 0px;" src="C:\Users\Public\Pictures\Sample%20Pictures" id="ctl00_ContentPlaceHolder1_Image1">
</div>
mysql中的字符集是拉丁语1和瑞典语或其他不确定如何再次找到它?
答案 0 :(得分:1)
我认为您的问题是Image1.ImageUrl
。这肯定会对传递给它的字符串进行URL编码。