后台有数据前台又不显示,如果不是你控制层等代码处理出错了,就是你接值的时候出问题了,你看下你用什么名字存在request或者session或者modle中的,前台又用什么接的值,如果接值得名称不一致,肯定会出问题,如果这里确定没问题,你用一下debug,看一下数值传到哪里就变空了,就只能是控制层等地方出错了
那个老师教你用datagridview显示!用pictureBox不是更好吗?我给你一段源程序!你好好看看!数据库我也给你!只是!
源代码如下:
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemText;
using SystemWindowsForms;
using SystemDataSqlClient;
using SystemIO;
using SystemDataSqlTypes;
namespace BLOB
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
UpdateTimeText = SystemDateTimeNowToString();
}
string PhotoName = "";
byte[] Pic;
private void BSelect_Click(object sender, EventArgs e)
{
openFileDialog1Filter = "选择(BMP;JPG;GIF)|BMP;JPG;GIF|All files()|";
if (openFileDialog1ShowDialog() == DialogResultOK)
{
pictureBox1Image = ImageFromFile(openFileDialog1FileName,true);//牛逼啊、、、、、、、、、、、、
PhotoName = openFileDialog1FileName;
PnameText = PhotoNameSubstring(PhotoNameLastIndexOf(@"\") + 1);//;;;;;;;;;;;;;;;;;;;1·11!!
}
else
{
MessageBoxShow("您还未选取", "提示", MessageBoxButtonsOK, MessageBoxIconInformation);
return;
}
}
private void BAdd_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=Contact;Integrated Security=True");
try
{
connOpen();
SqlCommand cmd = new SqlCommand("insert into BLOB values(@name,@time,@photo)", conn);
cmdParametersAddWithValue("@name", PnameText);
cmdParametersAddWithValue("@time", UpdateTimeText);
Pic = FileReadAllBytes(PhotoName);
cmdParametersAddWithValue("@photo", Pic);
cmdExecuteNonQuery();
connClose();
MessageBoxShow("插入数据成功!", "提示:", MessageBoxButtonsOKCancel, MessageBoxIconInformation);
}
catch (Exception ex)
{
MessageBoxShow(exToString());
}
}
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=Contact;Integrated Security=True");
if (connState == ConnectionStateClosed)
{
connOpen();
}
SqlCommand cmd = new SqlCommand("select name from BLOB",conn);
SqlDataReader dr = cmdExecuteReader();
while (drRead())
{
listItemsAdd(drGetString(0));
}
}
private void list_SelectedIndexChanged(object sender, EventArgs e)
{
if (listSelectedIndex == -1)
{
return;
}
else
{
SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=Contact;Integrated Security=True");
if (connState == ConnectionStateClosed)
{
connOpen();
}
string SelectItem = listSelectedItemToString();
SqlCommand cmd = new SqlCommand("Select from BLOB where name=@SelectItems",conn);
cmdParametersAddWithValue("@SelectItems", SelectItem);
SqlDataReader dr = cmdExecuteReader();
if (drRead())
{
PnameText = drGetString(0);
UpdateTimeText = drGetDateTime(1)ToString();
SqlBytes PhotoBytes = drGetSqlBytes(2);
pictureBox1Image = ImageFromStream(PhotoBytesStream);
}
drClose();
connClose(); //最好加上这两个CLOSE()方法!
}
}
}
}
数据库 和 C# 自己区分!我想你能看懂:
以上就是关于js前台不显示数据怎么回事,eclipse控制台中有返回的数据库的数值但是前台不显示,附图片求java大神解决全部的内容,包括:js前台不显示数据怎么回事,eclipse控制台中有返回的数据库的数值但是前台不显示,附图片求java大神解决、c# winform数据库中存储图片是二进制的,现在却不能在datagridview中显示出来,求高手支招。、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)