一次在数据库中保存多个图像路径URL [英] Saving Multiple Image Path url in Database at once

查看:183
本文介绍了一次在数据库中保存多个图像路径URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想立即在数据库中保存多个图像路径网址。

i want to Saving Multiple Image Path url in Database at once.

推荐答案

您可以设置一个循环来存储SQL数据库中文件的名称。例如,如果图像来自请求,您可能会编写此代码。



You can set a loop to store the names of the files in the SQL database. For example, if the images come from a request, you would possibly write this code.

foreach (var file in Request.Files) {
   // now get the name of each file
   var filename = file.FileName;
   // execute the following command, 
   var command = "INSERT INTO table_name (FileName) VALUES (@0)";
   // 0 is a parameter, update it. 
}





我没有为执行写任何代码,因为这取决于你是否是使用WebMatrix.Data的Database对象或者您正在使用SqlClient对象。



编辑



由于你使用的是SqlClient,你可以使用 SqlCommand [ ^ ]并执行它。结果将是受影响的行数(在INSERT INTO的情况下创建)。



I have not written any code for the execution, because it depends on whether you're using the Database object of WebMatrix.Data or you're using the SqlClient object.

Edit

Since you're using SqlClient, you can use the SqlCommand[^] and execute it. The result would be the number of rows affected (created in the case of INSERT INTO).


这篇关于一次在数据库中保存多个图像路径URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆