编写数据适配器sql命令 [英] writing data adapter sql commands

查看:75
本文介绍了编写数据适配器sql命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编写插入命令以处理数据表时遇到问题。

我已经查看了sqldataadapter创建的内容并创建了我的插入内容

命令看起来一样。我有:

MySqlAdapter.InsertCommand = New SqlCommand(" INSERT INTO billing(type,

dsc)VALUES(@ type,@ dsc)",MySqlConnection)


但当MySqlAdapter.Update(MyDt)

执行时,它会给我以下错误:必须声明变量''@type''


有人能告诉我我做错了吗?

解决方案

CJ,


如果你做了我写的,那就比你看到的直接解决你当前的问题了。


只需使用dataadapter向导临时创建你的SQL字符串并剪切

你的程序设计器部分将它们设置在运行时需要它们的方法中。


Insert命令需要 ;选取[用于查看数据是否未更改的代码

已经。


请保留原始帖子。


Cor


" cj" < cj@nospam.nospam> schrieb

我在编写插入命令以处理
数据表时遇到问题。我查看了sqldataadapter创建的内容,并创建了我的insert命令以使其看起来相同。我有:
MySqlAdapter.InsertCommand =新的SqlCommand(INSERT INTO计费(
type,dsc)VALUES(@ type,@ dsc)",MySqlConnection)

但是当MySqlAdapter.Update(MyDt)执行时,它会给我以下错误:必须声明变量''@type''

有人能告诉我我做错了吗? / blockquote>


看看@ microsoft.public.dotnet.framework.adonet


(你如何设置参数''的价值?)

Armin




对不起,这不行。我使用了创建此行的向导。


INSERT INTO billing(type,dsc)VALUES(@ type,@ dsc); SELECT类型,dsc

FROM billing


然后我在代码中使用了该命令并且它不起作用。它给了我

相同的错误。


必须声明变量''@ type''

Cor Ligthert [MVP]写道:

CJ,

如果你做了我写的,比你看到的直接解决你当前的问题。

只需临时使用dataadapter向导创建你的SQL字符串并剪切它们的程序设计器部分,以便在运行时需要它们的方法中设置它们。

Insert命令需要 ;选取[用于查看数据是否未更改的代码

请保留原始帖子。

Cor



I''m having a problem writing an insert command to work with a datatable.
I''ve looked at what the sqldataadapter creates and created my insert
command to look the same. I have:
MySqlAdapter.InsertCommand = New SqlCommand("INSERT INTO billing( type,
dsc ) VALUES ( @type, @dsc)", MySqlConnection)

But it gives me the following error when MySqlAdapter.Update(MyDt)
executes: Must declare the variable ''@type''

Could someone tell me what I''m doing wrong?

解决方案

CJ,

If you did what I wrote, than you had seen direct your current problem.

Just use the dataadapter wizard temporaly to create your SQL strings and cut
them of the designer part of your program to set them in the method where
you need them at runtime.

The Insert command needs the "Select" code to see if the data is not changed
already.

Please keep it to the original thread.

Cor


"cj" <cj@nospam.nospam> schrieb

I''m having a problem writing an insert command to work with a
datatable. I''ve looked at what the sqldataadapter creates and
created my insert command to look the same. I have:
MySqlAdapter.InsertCommand = New SqlCommand("INSERT INTO billing(
type, dsc ) VALUES ( @type, @dsc)", MySqlConnection)

But it gives me the following error when MySqlAdapter.Update(MyDt)
executes: Must declare the variable ''@type''

Could someone tell me what I''m doing wrong?



Have a look @ microsoft.public.dotnet.framework.adonet

(how do you set the parameters'' value?)
Armin



Sorry, that doesn''t work. I used the wizard which created this line.

INSERT INTO billing(type, dsc) VALUES(@type, @dsc); SELECT type, dsc
FROM billing

I then used that command in code and it doesn''t work. It gives me the
same error.

Must declare the variable ''@type''
Cor Ligthert [MVP] wrote:

CJ,

If you did what I wrote, than you had seen direct your current problem.

Just use the dataadapter wizard temporaly to create your SQL strings and cut
them of the designer part of your program to set them in the method where
you need them at runtime.

The Insert command needs the "Select" code to see if the data is not changed
already.

Please keep it to the original thread.

Cor



这篇关于编写数据适配器sql命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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