如何在可变的SQL值存储 [英] How to SQL value store in varaiable

查看:60
本文介绍了如何在可变的SQL值存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MsSql = ""
MsSql &= "Select tsalesdump_gid,tsalesdump_date,tsalesdump_name,executivename_executive,tsalesdump_vch_no,tsalesdump_debit,tsalesdump_credit"
MsSql &= " from vsolv_tmp_tsalesdump as a"
MsSql &= " left join vsolv_trn_executivename as b on a.tsalesdump_name = b.executivename_particulars"
MsSql &= " where tsalesdump_gid = '" & lsRefid & "' and tsalesdump_isremoved = 'N'"
dtDumpBooking = Gobjdbconn.GetDataTable(MsSql)

MsSql = ""
MsSql &= " SELECT tsalesdump_date,tsalesdump_name,tsalesdump_vch_no FROM"
MsSql &= " ( SELECT tsalesdump_date,tsalesdump_name,tsalesdump_vch_no FROM vsolv_tmp_tsalesdump"
MsSql &= "  UNION"
MsSql &= " SELECT tsalesregdump_date,tsalesregdump_name,tsalesregdump_vch_no FROM vsolv_trn_tsalesregdump"
MsSql &= " ) A order by tsalesdump_vch_no asc; "
dtdumpsample = Gobjdbconn.GetDataTable(MsSql)





我尝试过:



如何变量存储在sql数据中



如果两个sql数据相同则不好更新而且它不一样它去插入怎么能使用它

asp.net vb



What I have tried:

how to variable to store in sql data

if the two sql data is same it ill be update and its not same its go to insert how can use it
asp.net vb

推荐答案

你好b $ b

有两种方法可以做这个



1.您可以使用linq从您的条件中获取数据表中的数据并将其存储在变量中



2.您可以创建匿名对象并将数据存储到其中



C#





var obj1 = new obj1

{

tsalesdumpgid = dtDumpBooking.rows [index] [columnname] .tostring(),

tsalesdumpname = dtDumpBooking.rows [index] [columnname] .tostring(),

executivenameexecutive = dtDumpBooking.rows [index] [columnname] .tostring()

};





var obj2 = new obj2

{

tsalesdumpdate = dtdumpsample .rows [index] [columnname] .tostring(),

tsalesdumpname = dtdumpsample .rows [index] [columnname] .tostring()



};





if(obj1 == obj2)

{

//你的代码



}



VB





Dim obj1 = New obj1(){_

Key .tsalesdumpgid = dtDumpBooking.rows(index)(columnname ).tostring(),_

Key .tsalesdumpname = dtDumpBooking.rows(index)(columnname).tostring(),_

Key .executivenameexecutive = dtDumpBooking.rows( index)(columnname).tostring()_

}







Dim obj2 = New obj2(){_

Key .tsalesdumpdate = dtdumpsample.rows(index)(columnname).tostring(),_

Key .tsalesdumpname = dtdumpsample.rows(index)(columnname).tostring()_

}









如果obj1 = obj2那么

//你的代码

结束如果









以上代码只是一个例子
Hi
Two ways are there to do this

1.You can use linq to get the data from datatable with your condition and store it in variable

2.You can create anonymous objects and store your data into it

C#


var obj1=new obj1
{
tsalesdumpgid=dtDumpBooking.rows[index][columnname].tostring(),
tsalesdumpname=dtDumpBooking.rows[index][columnname].tostring(),
executivenameexecutive=dtDumpBooking.rows[index][columnname].tostring()
};


var obj2=new obj2
{
tsalesdumpdate=dtdumpsample .rows[index][columnname].tostring(),
tsalesdumpname=dtdumpsample .rows[index][columnname].tostring()

};


if(obj1==obj2)
{
//your code

}

VB


Dim obj1 = New obj1() With { _
Key .tsalesdumpgid = dtDumpBooking.rows(index)(columnname).tostring(), _
Key .tsalesdumpname = dtDumpBooking.rows(index)(columnname).tostring(), _
Key .executivenameexecutive = dtDumpBooking.rows(index)(columnname).tostring() _
}



Dim obj2 = New obj2() With { _
Key .tsalesdumpdate = dtdumpsample.rows(index)(columnname).tostring(), _
Key .tsalesdumpname = dtdumpsample.rows(index)(columnname).tostring() _
}




If obj1 = obj2 Then
//your code
End If




The above code is just an example only


这篇关于如何在可变的SQL值存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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