using System.Data.SqlClient;SqlConnection connection;
SqlConnection connection2;string fn = System.IO.Path.GetFileName(HIF.PostedFile.FileName);//获取文件名
string flvmappath = LocalPath + fn;//获取上传路径+文件名
string connectionString = ConfigurationManager.ConnectionStrings["UploadfilesConnectionString"].ConnectionString;//连接数据库的字符串
//进行第一张表的操作//获取fn给Flvoriginalname,获取Flvtype给FlvType,获取loaclpath给FlvLoaclPath
using (connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand
("INSERT INTO dbo.FlvInformation (FlvOriginalName, FlvType, FlvLoaclPath) VALUES (@fn, @FlvType, @LoaclPath)",connection);
connconnection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@fn", fn);
cmd.Parameters.AddWithValue("@Flvtype", Flvtype);
cmd.Parameters.AddWithValue("@LoaclPath", LocalPath);
}
//进行第二张表的操作//获取Flvinformation给OperationRecords表的OperationRecords
using (connection2 = new SqlConnection(connection2))
{
connection2 = new SqlConnection(connectionString);
SqlCommand cmd2 = new SqlCommand
("insert into dbo.OperationRecords (OperationRecords) VALUES (@FlvInformation)", connection2);
connconnection2.Open();
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@Flvinformation", Flvinformation);
}编译通过,但是数据库里无数据? 哪里出错了?
解决方案 »
- c#遍历数据库中的父子关系字段
- 前台页面刷新33次,页面上绑定数据库的信息自动消失
- Jquery dialog 弹出框问题...谢谢
- 求救:ODBC 驱动程序不支持所需的属性
- 有关上传网页的问题!
- 为什么点击按钮提交后,重开了一个session
- 技术难题:有可能通过系统判断某个图片是否为色情图片吗?
- 求在web中调用asp.netwinform
- 十分紧急 ....是关于 把数据库里的基本数据 以一种方式(如.xls .doc)显示在网页上
- DataList的一个问题。。。
- |zyciis| 为什么VS2010在运行了一段时间之后总是有延迟 为什么呢? 你们会不会有这种情况 谢谢
- net3.5下web.config转化为.net2.0下的web.config
你只是打开了连接,并没有执行这条语句,怎么会有数据呢?
connconnection2.Open();
cmd2.ExecuteNonQuery();
connconnection2.Close();
connconnection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@fn", fn);
cmd.Parameters.AddWithValue("@Flvtype", Flvtype);
cmd.Parameters.AddWithValue("@LoaclPath", LocalPath);
cmd.ExecuteNonQuery();
connconnection.Close();-------------connconnection2.Open();
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@Flvinformation", Flvinformation);cmd2.ExecuteNonQuery();
connconnection2.Close();
string flvmappath = LocalPath + fn;//获取上传路径+文件名
string connectionString = ConfigurationManager.ConnectionStrings["UploadfilesConnectionString"].ConnectionString;//连接数据库的字符串
//进行第一张表的操作//获取fn给Flvoriginalname,获取Flvtype给FlvType,获取loaclpath给FlvLoaclPath
using (connection = new SqlConnection(connectionString))
{
connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand
("INSERT INTO dbo.FlvInformation (FlvOriginalName, FlvType, FlvLoaclPath) VALUES (@fn, @FlvType, @LoaclPath)",connection);
connection.Open();
cmd.Parameters.AddWithValue("@fn", fn);
cmd.Parameters.AddWithValue("@Flvtype", Flvtype);
cmd.Parameters.AddWithValue("@LoaclPath", LocalPath);
cmd.ExecuteNonQuery();
connection.Close();
}
//进行第二张表的操作//获取Flvinformation给OperationRecords表的OperationRecords
using (connection2 = new SqlConnection(connectionString))
{
connection2 = new SqlConnection(connectionString);
SqlCommand cmd2 = new SqlCommand
("insert into dbo.OperationRecords (OperationRecords) VALUES (@FlvInformation)", connection2);
connection2.Open();
cmd2.Parameters.AddWithValue("@Flvinformation", Flvinformation);
cmd2.ExecuteNonQuery();
connection2.Close();
}