DataAdapter与编码 [英] DataAdapter vs Coding

查看:49
本文介绍了DataAdapter与编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助理解以下内容:


当我创建项目并使用Dim connectString编码我的连接时

As String =" Provider = Microsoft.Jet.OLEDB.4.0;" &安培; 数据

源= C:\ Temp \NW-test.MDB,当我运行

项目时一切正常。


但是,如果我使用DataAdapter向导设置完全相同的连接

并尝试运行该项目,我得到一个Microsoft Jet数据库引擎不能

打开文件......错误。


我不明白为什么项目使用编码

连接正确运行,但在使用DataAdapter向导时总是失败。


非常感谢任何帮助。


谢谢,


TJ

解决方案

使用DataAdapter,您仍然可以正常设置连接(连接

string和all)。

Dim con as New OleDb.OleDbConnection(" Provider = ...")

Dim da as New OleDb.OleDbDataAdapter(" SELECT .... FROM ... ",con)

Dim ds作为新数据集

da.Fill(ds,srcTableName)


此时你将包含一个包含

的表的数据集,无论您指定的数据是什么。

" TJ Doherty" < TJ ******* @ discussions.microsoft.com>在消息中写道

news:95 ********************************** @ microsof t.com ...

需要帮助理解以下内容:

当我创建项目并使用Dim编码我的连接时
connectString
As String =" Provider = Microsoft.Jet.OLEDB.4.0;" &安培; Data
Source = C:\Temp \NW-test.MDB,当我运行
项目时,一切正常。

但是,如果我设置了完全相同的连接使用DataAdapter
并尝试运行该项目,我得到一个Microsoft Jet数据库引擎无法打开文件......错误。

我不明白为什么项目使用编码
连接正确运行但在使用DataAdapter向导时总是失败。

任何非常感谢帮助。

谢谢,

TJ



他问为什么向导是失败


" Scott M." < S - *** @ nospam.nospam>写在消息

新闻:ez ************** @ TK2MSFTNGP09.phx.gbl ...

使用DataAdapter,你仍然正常设置您的连接(连接
字符串和所有)。

Dim con as New OleDb.OleDbConnection(" Provider = ...")
Dim da as new OleDb.OleDbDataAdapter(" SELECT .... FROM ..." con)
Dim ds as New DataSet
da.Fill(ds,srcTableName)

>此时,您将拥有一个DataSet,其中包含一个表,其中包含SELECT指定的任何数据。

" TJ Doherty" < TJ ******* @ discussions.microsoft.com>在消息中写道
新闻:95 ********************************** @ microsof t.com。 ..

需要帮助理解以下内容:

当我创建项目并使用Dim编码我的连接时
connectString
As String =" ;提供商= Microsoft.Jet.OLEDB.4.0;" &安培; Data
Source = C:\Temp \NW-test.MDB,当我运行
项目时,一切正常。

但是,如果我设置了完全相同的连接使用DataAdapter
并尝试运行该项目,我得到一个Microsoft Jet数据库引擎
无法打开该文件...错误。

我不明白为什么项目使用编码
连接正确运行但在使用DataAdapter向导时总是失败。

任何非常感谢帮助。

谢谢,

TJ




< blockquote>实际上,他说他使用向导设置了一个DataAdapter,当项目运行时,它就是
,它失败了。他没有说巫师失败了。所以,

使用下面的代码(或使用向导生成下面的代码),

他可以看出他是否有VS问题或只是编码问题。 (我怀疑

他没有使用你需要写的da.fill,即使你使用了

向导)。

杰夫狄龙 < JE ** @ removeemergencyreporting.com>在留言中写道

news:ur ************** @ TK2MSFTNGP09.phx.gbl ...

他问为什么向导失败

Scott M. < S - *** @ nospam.nospam>在消息中写道
新闻:ez ************** @ TK2MSFTNGP09.phx.gbl ...

使用DataAdapter,你仍然设置你的连接正常
(连接
字符串和所有)。

Dim con as New OleDb.OleDbConnection(" Provider = ...")
Dim da as new OleDb.OleDbDataAdapter(" SELECT .... FROM ..." con)
Dim ds as New DataSet
da.Fill(ds,srcTableName)

>此时,您将拥有一个DataSet,其中包含一个表,其中包含SELECT指定的任何数据。

" TJ Doherty" < TJ ******* @ discussions.microsoft.com>在消息中写道
新闻:95 ********************************** @ microsof t.com。 ..

>需要帮助理解以下内容:
>
>当我创建一个项目并使用Dim编写我的连接时
> connectString
> As String =" Provider = Microsoft.Jet.OLEDB.4.0;" &安培; 数据
> Source = C:\Temp \NW-test.MDB"当我运行
>时一切正常项目。
>
>但是,如果我使用DataAdapter设置完全相同的连接
>向导
>并尝试运行该项目,我得到一个Microsoft Jet数据库引擎不能>打开文件......错误。
>
>我不明白为什么项目使用编码
>正确运行连接但在使用DataAdapter向导时总是失败。
>
>非常感谢任何帮助。
>
>谢谢,
>
> TJ





Need help understanding the following please:

When I am creating a project and code my connection using Dim connectString
As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\Temp\NW-test.MDB", everything works correctly when I run the
project.

However, if I set up the exact same connection using the DataAdapter wizard
and try to run the project, I get a "Microsoft Jet database engine cannot
open the file..." error.

I don''t understand why the project runs correctly using the "coded"
connection but always fails when using the DataAdapter wizard.

Any assistance would be greatly appreciated.

Thanks,

TJ

解决方案

With a DataAdapter, you still set up your connection as normal (connection
string and all).

Dim con as New OleDb.OleDbConnection("Provider=...")
Dim da as New OleDb.OleDbDataAdapter("SELECT .... FROM ...", con)
Dim ds as New DataSet
da.Fill(ds,srcTableName)

At this point you will have a DataSet containing a table that contains
whatever data your SELECT specified.
"TJ Doherty" <TJ*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...

Need help understanding the following please:

When I am creating a project and code my connection using Dim
connectString
As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\Temp\NW-test.MDB", everything works correctly when I run the
project.

However, if I set up the exact same connection using the DataAdapter
wizard
and try to run the project, I get a "Microsoft Jet database engine cannot
open the file..." error.

I don''t understand why the project runs correctly using the "coded"
connection but always fails when using the DataAdapter wizard.

Any assistance would be greatly appreciated.

Thanks,

TJ



He asked why the Wizard is failing

"Scott M." <s-***@nospam.nospam> wrote in message
news:ez**************@TK2MSFTNGP09.phx.gbl...

With a DataAdapter, you still set up your connection as normal (connection
string and all).

Dim con as New OleDb.OleDbConnection("Provider=...")
Dim da as New OleDb.OleDbDataAdapter("SELECT .... FROM ...", con)
Dim ds as New DataSet
da.Fill(ds,srcTableName)

At this point you will have a DataSet containing a table that contains
whatever data your SELECT specified.
"TJ Doherty" <TJ*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...

Need help understanding the following please:

When I am creating a project and code my connection using Dim
connectString
As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\Temp\NW-test.MDB", everything works correctly when I run the
project.

However, if I set up the exact same connection using the DataAdapter
wizard
and try to run the project, I get a "Microsoft Jet database engine cannot open the file..." error.

I don''t understand why the project runs correctly using the "coded"
connection but always fails when using the DataAdapter wizard.

Any assistance would be greatly appreciated.

Thanks,

TJ




Actually, he said that he set up a DataAdapter using the wizard and that
when the project runs, it fails. He did not say that the wizard fails. So,
by using my code below (or by using the wizard to generate the code below),
he can see if he has a VS problem or just a coding problem. (I suspect that
he didn''t use the da.fill which you need to still write even if you use the
wizard).
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...

He asked why the Wizard is failing

"Scott M." <s-***@nospam.nospam> wrote in message
news:ez**************@TK2MSFTNGP09.phx.gbl...

With a DataAdapter, you still set up your connection as normal
(connection
string and all).

Dim con as New OleDb.OleDbConnection("Provider=...")
Dim da as New OleDb.OleDbDataAdapter("SELECT .... FROM ...", con)
Dim ds as New DataSet
da.Fill(ds,srcTableName)

At this point you will have a DataSet containing a table that contains
whatever data your SELECT specified.
"TJ Doherty" <TJ*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...

> Need help understanding the following please:
>
> When I am creating a project and code my connection using Dim
> connectString
> As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
> Source=C:\Temp\NW-test.MDB", everything works correctly when I run the
> project.
>
> However, if I set up the exact same connection using the DataAdapter
> wizard
> and try to run the project, I get a "Microsoft Jet database engine cannot > open the file..." error.
>
> I don''t understand why the project runs correctly using the "coded"
> connection but always fails when using the DataAdapter wizard.
>
> Any assistance would be greatly appreciated.
>
> Thanks,
>
> TJ





这篇关于DataAdapter与编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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