Noobish:搜索没有绑定到对象的mdf数据... [英] Noobish: Search mdf data WITHOUT binding to object...

查看:83
本文介绍了Noobish:搜索没有绑定到对象的mdf数据...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我已经失去了半天的时间来对抗这一个,而且我已经发出了一个求救电话......


这很简单,令人尴尬。然而,VC#2005 Express已经让你的东西变得如此强大,以至于他们很难找到怎么做

简单的东西没有拖拽和放大器;删除工具。


这是用于访问.mdb文件的示例中的代码:

******** ************

foreach(系统.Data.DataRow theRow in ds.Tables [" BackChat"]。行)

{

if(sCommand == theRow [" Command"]。ToString())

{

string sResponse = theRow [" Response" ;]。ToString();

string sAction = theRow [" Action1"]。ToString();


if(sResponse!="" ;)

{/////////////在这里做点什么......

************ ********


它不在BackChat之内。 SAPI5.1的样本,如果您熟悉的话。


以下是问题(是的,我有问题!哈哈):


使用我自己的数据集的各种变体都让我失望了。无论我做什么,我能做到的最好的就是Row标题的刺痛,而不是单元格本身的内容。


我已经尝试过这么多,我甚至都不记得了......大脑已经煮熟了,是时候休息一下了因为我只是向后退。


我需要做的只是比较命令中列出的所有值。

列,看它们是否匹配var。据我所知,这是最好的

与foreach()接近。


注意:没有图形化,可点击的方式将数据绑定设置为一个

特定行,因为没有控制将它绑定到!!!如果这里涉及到这样的控制,那么我现在已经很久没过了。


任何有SpSharedRecoContext()经验的人都应该明白我是在一微秒内停留在
。如果您了解如何使用它,或者如何在不使用图形化的

工具的情况下在基于.mdf的数据集中查找

特定条目,我一定会感谢您的建议。


谢谢!


Scott


-

使用Opera革命性的电子邮件客户端: http://www.opera.com/ mail /

Ok, I''ve lost half a day to pounding my head against this one and I''m
sending out a distress call...

This is so simple that it''s emberassing. However, VC# 2005 Express has
made things so monkey-proof that they made it hard to find out how to do
the simple things that don''t have drag&drop tools.

This is the code in the sample that is being used to access an .mdb file:
********************
foreach (System.Data.DataRow theRow in ds.Tables["BackChat"].Rows)
{
if (sCommand == theRow["Command"].ToString())
{
string sResponse = theRow["Response"].ToString();
string sAction = theRow["Action1"].ToString();

if (sResponse != "")
{ ///////////// Do things here...
********************

It''s out of the "BackChat" sample for SAPI5.1, if you''re familiar with it.

Here are the issues (yea, I have issues! lol) :

All sorts of variants using my own dataSet are failing me. No matter what
I do, the best I can get it to return is the sting of the Row header, not
the contents of the cells themselves.

I''ve tried so many that I can''t even remember them anymore... the brain is
cooked and it''s time to take a break because I''m only going backward.

What I need to do is simply compare all the values listed in the "Command"
column to see if they match a var. As far as I know, this is best
approached with a foreach ().

NOTE: There is no graphical, clickable way to set the databinding to a
specific row because there is no control to bind it to!!! If there were
such a control involved here, I''d be long past this point by now.

Anyone with SpSharedRecoContext() experience should understand where I''m
stuck in a microsecond. If you understand how to use that, or how to find
specific entries in your .mdf based dataSet without using the graphical
tools, I''d sure appreciate your advice.

Thanks!

Scott

--
Using Opera''s revolutionary e-mail client: http://www.opera.com/mail/

推荐答案

Scott写道:
Scott wrote:

以下是问题(是的,我有问题!哈哈):


使用我自己的数据集的各种变种都让我失望。无论我做什么,我能做到的最好的就是行

标题的刺痛,而不是单元格本身的内容。
Here are the issues (yea, I have issues! lol) :

All sorts of variants using my own dataSet are failing me. No matter
what I do, the best I can get it to return is the sting of the Row
header, not the contents of the cells themselves.



好​​的,你已经从样本中展示了代码,但显然那不是代码

你是使用。你能告诉你现在正在尝试什么吗?那肯定会给你
帮助。

OK, you''ve showed the code from a sample, but apparently that''s not the code
you''re using. Can you show what you''re trying now? That''ll definitely
help.


>

我试过这么多我甚至不能再记住它了......

的大脑已煮熟了,是时候休息了,因为我只会向后退货。

我需要做的只是比较

" Command"中所列的所有值。列,以查看它们是否与var匹配。据我所知,这个

最好用foreach()接近。
>
I''ve tried so many that I can''t even remember them anymore... the
brain is cooked and it''s time to take a break because I''m only going
backward.
What I need to do is simply compare all the values listed in the
"Command" column to see if they match a var. As far as I know, this
is best approached with a foreach ().



看看DataTable.Select。这很简单:


foreach(DataRow dr in

theTable.Select(string.Format(" Command =''{0} ''',sCom mand)))

{

//所有匹配的行将逐一返回

}

Take a look at DataTable.Select. It''s as easy as:

foreach (DataRow dr in
theTable.Select(string.Format("Command=''{0}''",sCom mand)))
{
// all of the matching rows will be returned one by one
}


>

注意:没有图形化,可点击的方式将数据绑定设置为

特定行因为没有控制来绑定它!如果这里涉及到这样的控制,那么我现在已经很久了。
>
NOTE: There is no graphical, clickable way to set the databinding to a
specific row because there is no control to bind it to!!! If there
were such a control involved here, I''d be long past this point by now.



我的建议:首先学习如何使用低级(er)级别,然后学习
了解数据绑定如何适应图片。它不是灵丹妙药。


HTH


-cd

My recommendation: learn how to use the low(er) level classes first, then
learn how data binding fits into the picture. It''s not a panacea.

HTH

-cd


在Sun,2006年7月30日17:51:17 -0400,Carl Daniel [VC ++ MVP]

< cp ******************* **********@mvps.org.nospamwr ote:
On Sun, 30 Jul 2006 17:51:17 -0400, Carl Daniel [VC++ MVP]
<cp*****************************@mvps.org.nospamwr ote:

我的建议:首先学习如何使用低级(er)级别,

然后学习数据绑定如何适应图片。它不是灵丹妙药..
My recommendation: learn how to use the low(er) level classes first,
then learn how data binding fits into the picture. It''s not a panacea..



哦,我知道。麻烦的是你必须选择一个要关注的区域,否则你会得到太多的信息。我看过DataTable.Select和

开始变得有点旋转,因为我似乎找不到它的方式

适合我的dataSet,bindingSource, bindingNavigator或我的tableAdapeter。


在绝大多数情况下,拖放很容易......在某些方面太简单了。因为当你需要手动完成时,你可能不会知道怎么做。在处理SAPI时,有一些com对象,但是,据我所知,将它们绑定到某些字段并不像使用

文本框那样容易。


我坐在这里以为我应该发布一些代码,但没有什么是

接近功能所以我不知道该发布什么LOL 。这是当前的,

坏了,版本:


******************* *


private void testDbRetrieval()

{

//此字符串是命令中的第一个条目

string sCommands =" Sabine,你在吗?                  。

foreach(DataRow dr in

sabineCommandsDataGridView.Select(string.Format(" C ommand =''{0}''",

sCommands)))


{

// *** BROKEN ***设置字符串resp等于
的值
响应在正确的索引处行...

string resp =

sabineCommandsDataGridView.Select(String.Format(" R esponse =''{0}''") );


//说出给定命令的相应响应

voice.Speak(resp,SpeechVoiceSpeakFlags.SVSFDefault);

}


}


*******************


感谢您的帮助!我理解TTS没问题,一旦事情变得复杂,各种

上下文需要在树中。我也理解

关于关闭命令应用程序的改编以及为什么需要

来防止降级...这是偶尔的,非常痛苦的简单,

基本面让我背上了我!


Scott

-

使用Opera革命性的电子邮件客户端: http://www.opera.com/ mail /


Scott,

你发布的内容看起来好像你可能会混淆DataGridView
使用DataTable.Select方法选择方法(选择行),其中
更多是Sql类型的过滤器。声明。卡尔的建议是合适的

恕我直言。

彼得


-

创始人,Eggheadcafe.com开发者门户网站:
http://www.eggheadcafe.com

UnBlog:
http://petesbloggerama.blogspot.com


" Scott"写道:
Scott,
from what you''ve posted it looks like you may be confusing the DataGridView
Select method(which selects a "Row") with the DataTable.Select method, which
is more of a Sql - type "filter" statement. Carl''s advice was appropriate
IMHO.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Scott" wrote:

On Sun,2006年7月30日17:51:17 -0400,Carl Daniel [VC ++ MVP]

< cp * ****************************@mvps.org.nospamwr ote:
On Sun, 30 Jul 2006 17:51:17 -0400, Carl Daniel [VC++ MVP]
<cp*****************************@mvps.org.nospamwr ote:

我的建议:首先学习如何使用低级(呃)级别,然后学习数据绑定如何适应图片。它不是灵丹妙药..
My recommendation: learn how to use the low(er) level classes first,
then learn how data binding fits into the picture. It''s not a panacea..



哦,我知道。麻烦的是你必须选择一个要关注的区域,否则你会得到太多的信息。我看过DataTable.Select和

开始变得有点旋转,因为我似乎找不到它的方式

适合我的dataSet,bindingSource, bindingNavigator或我的tableAdapeter。


在绝大多数情况下,拖放很容易......在某些方面太简单了。因为当你需要手动完成时,你可能不会知道怎么做。在处理SAPI时,有一些com对象,但是,据我所知,将它们绑定到某些字段并不像使用

文本框那样容易。


我坐在这里以为我应该发布一些代码,但没有什么是

接近功能所以我不知道该发布什么LOL 。这是当前的,

坏了,版本:


******************* *


private void testDbRetrieval()

{

//此字符串是命令中的第一个条目

string sCommands =" Sabine,你在吗?                  。

foreach(DataRow dr in

sabineCommandsDataGridView.Select(string.Format(" C ommand =''{0}''",

sCommands)))


{

// *** BROKEN ***设置字符串resp等于
的值
响应在正确的索引处行...

string resp =

sabineCommandsDataGridView.Select(String.Format(" R esponse =''{0}''") );


//说出给定命令的相应响应

voice.Speak(resp,SpeechVoiceSpeakFlags.SVSFDefault);

}


}


*******************


感谢您的帮助!我理解TTS没问题,一旦事情变得复杂,各种

上下文需要在树中。我也理解

关于关闭命令应用程序的改编以及为什么需要

来防止降级...这是偶尔的,非常痛苦的简单,

基本面让我背上了我!


Scott


-

使用Opera革命性的电子邮件客户端: http:// www。 opera.com/mail/


这篇关于Noobish:搜索没有绑定到对象的mdf数据...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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