我们可以将Datatype作为参数传递给函数,然后使用该数据类型转换数据,这也是我作为参数传递的数据 [英] Can We pass Datatype as argumet to function and then That datatype use to convert data which is also i am passing as argument

查看:171
本文介绍了我们可以将Datatype作为参数传递给函数,然后使用该数据类型转换数据,这也是我作为参数传递的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii



我必须将80个字段传递给数据库,这是大多数不同类型的数据库。

所以代码在文件后面我想要检查类型,并且必须将其转换为数据库类型,因为值是从文本框访问的。



所以我想制作方法,其中生病检查数据在哪里空(如果为空然后发送DBNULL.Value)

如果没有那么转换为数据类型,其作为参数传递



这是否可能

我怎样才能实现它



请帮助.... !!!

hii

I Have to pass around 80 fields to database which is most of different type.
so in code behind file I want to check the type and and have to convert it to db type as value is accessing from textbox.

so I want to make method in which ill check data where its empty (if empty then send DBNULL.Value)
and if not then convert to datatype which ill pass as argument

Is this possible
how can i achieve it

please help....!!!

推荐答案

你为什么要这样?

一定要检查一下 - 无论如何这都是个好主意。

但是如果你传递了价值作为使用 SqlCommand.Parameters.AddWithValue 方法的参数,您根本不需要进行任何其他转换 - 它将为您整理出来。
Why would you want to?
Check for null by all means - it''s a good idea to do that anyway.
But if you pass the value as a parameter using the SqlCommand.Parameters.AddWithValue method, you need do no other conversion at all - it will be sorted out for you.


这篇关于我们可以将Datatype作为参数传递给函数,然后使用该数据类型转换数据,这也是我作为参数传递的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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