为每个计算的日期发送SQL字符串 [英] Sending SQL string in for every calculated date

查看:85
本文介绍了为每个计算的日期发送SQL字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我现在有一个sql字符串,我需要在两个日期之间的每一天发送它。比如,如果您的第一个日期是01.01.0001,最后一个日期是03.01.0001那么,该字符串应该在每个日期发送3次(01. + 02. + 03.01.0001)



当我需要为每个选定的会员ID发送字符串时,我可以将其集成到我的脚本中吗?



这意味着,如果我有3个ID,3天,每个ID = 3个字符串将有3个字符串。



请注意,日期是动态的以及ID的数量。



我尝试过:



Hello there,

I have a sql string now, and I need to send it in, for every day between 2 dates. like, if the first date yould be, 01.01.0001 and the last date would be 03.01.0001 then, the string should be send 3 times in with every date (01. + 02. + 03.01.0001)

Any ideas for I can integrate that in my script when I already need to send the string in for every selected member ID?

That means, if I have 3 IDs, and 3 days, there would be 3 strings for every ID = 9 strings per total.

Please note, that the dates are dynamic as well as the amout of IDs.

What I have tried:

foreach (DataRow row in m_dt.Rows) {
                foreach (var item in row.ItemArray) {
                    string sqlString = "INSERT INTO [table] ([id] ,[day] ,[month] ,[year]) VALUES('" + item + "', '" + reason + "', '10', '08', '2016', '1' )";
                    Sendin( sqlString );
                }

推荐答案

请阅读解决方案循环:



SQL Server循环 - 如何循环浏览一组记录 - Stack Overflow [ ^ ]
Please read the solution to loop through:

SQL Server loop - how do I loop through a set of records - Stack Overflow[^]


这篇关于为每个计算的日期发送SQL字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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