请教:用SQL SELECT 数据源建立的多表字段的数据窗口,如何RETRIEVE 数据?

snw00100 2003-08-21 06:25:20
请问各位老师和朋友:用SQL SELECT 数据源建立的多表字段的数据窗口,如何浏览数据?请不吝赐教!谢谢!
...全文
103 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
snw00100 2003-08-23
  • 打赏
  • 举报
回复
谢谢各位!
怎样建立关联合适?
tylike 2003-08-23
  • 打赏
  • 举报
回复
查找关于inner join/left join/right join方式可以找到答案吧
snowarea 2003-08-22
  • 打赏
  • 举报
回复
看你的关联
如果存在一个表中没数据那你的数据窗口就不会有数据,
jackzhang168 2003-08-22
  • 打赏
  • 举报
回复
^_^,关联
用左连接,右连接啊
snw00100 2003-08-22
  • 打赏
  • 举报
回复
是用的SQL SERVER,但我不知道什么查询分析器。
刚才试了一下:如果每个表都有数据的前提下,可以检索到数据,但是只要有一个表没有数据就检索不到,并且每一个用户的合计数都一样?
谢谢WOEKHAND!
workhand 2003-08-22
  • 打赏
  • 举报
回复
在查询分析器里执行有数据吗?你是用sql server 吗?
snw00100 2003-08-22
  • 打赏
  • 举报
回复
SELECT client.c_name,
HUIKUAN.HK_MONEY,
SALE.S_PRICE,
SALE.S_QUANTITY,
TH.TH_PRICE,
TH.TH_SL
FROM client,
HUIKUAN,
SALE,
TH
WHERE ( HUIKUAN.C_NAME = SALE.C_NAME ) and
( SALE.C_NAME = TH.C_NAME ) and
( client.c_name = HUIKUAN.C_NAME )
nhdj 2003-08-21
  • 打赏
  • 举报
回复
关联的表真不少啊,贴出你的sql来看看,分析一下
snw00100 2003-08-21
  • 打赏
  • 举报
回复
说明白一点吧:
我正学PB,练习做销售管理,建了用户表、销售表、回款表和退货表。从用户表中分别取出用户名字段、从销售表中取出单价*数量的合计、从回款表中取出单回款额的合计、从退货表中取出单价*退货数量的合计。结果任何数据也浏览不到。
谢谢!
snw00100 2003-08-21
  • 打赏
  • 举报
回复
谢谢KLBT:我没建任何关联,只是每个表有一个共同的字段。谢谢!
klbt 2003-08-21
  • 打赏
  • 举报
回复
你的关联关系可能有问题。一个办法:
可以先close一个表,看是否出数据,不行再close一个表... ...
就可以分析出了
snw00100 2003-08-21
  • 打赏
  • 举报
回复
谢谢“清风”,可是检索不到任何数据,我想与几个表间的关系有关,但不知怎样实现?谢谢!
runsoft 2003-08-21
  • 打赏
  • 举报
回复
没有什么差别呀,点BROWSE图标就可以呀.
数据窗口源码介绍 (举例见d_dbit_example.srd,测试数据库为PB自带的EAS Demo DB V120) 1.第一行:release 12; 数据窗口所属PB的版本号,如果想把高版本的datawindow导入低版本的PB中要修改此数字; 2.datawindow()行 通常用修改processing属性,可以把你的数据窗口由grid变成freeform或其它类型 例:freeform:0 grid:1 3.header()行 可以整行复制粘贴,并命名为header[1],header[2],这样可以让数据窗口有多个header 4.table()行 这里全是定义的数据属性,是setitem,update,object.data等方法访问的根源 如果存在table()里的column,数据窗口里可以不存在任何对象,仍然可以访问数据窗口数据 如果想创建一个空的数据窗口,可以只定义: release 12; table() 5.table(column行) 是第几个column,它的ID就是多少,其中也定义了是否可以update时和更新到数据表的字段名 6.table(retrieve行) 检索数据时使用的SQL语句,可以通过setsqlselect或modify("table.sqlselect")方法去动态修改 修改后要重新定义数据窗口的更新属性 7.column()行 id即是对应table(column行)里的行次,名称(name)可以随便命名,也可以没有,则默认为table(column行)里的name 8.compute()行 计算列,可以通过表达式计算显示特定值(具体函数可以见共享里的画笔函数). 9.text()行 有时可以代替计算列; 通过定义text的表达式,可以实现一列中显示两个字段值,注意结果必须要转换成string类型(而column和compute则不行); 10.htmltable()行 按照格式导出(saveas)html文件,为了保证格式的完整,数据窗口的单位最好设置成pixels GenerateCSS='1' //保持格式及颜色 Border='0' //不要table边框 CellSpacing='0' //单元格无间距(此项在界面上经常设置不上) 注: (1)Grid生成标签,Freeform生成
+ 标签; (2)生成htmltable时,不知为何会在CSS中的开始自动加一个分号";",导致excel等浏览器打开不能正常显示格式; (3)band为foreground或background的对象导不出来,可以动态修改后再导出. 11.export.xml()行 定义导出xml文件的格式,并为模板保存名称 使用时一定要设置usetemplate值 12.import.xml()行 定义导入xml文件的格式,并为模板保存名称 使用时一定要设置usetemplate值 13.表达式介绍 略 14.其它也略
下面的控制台应用程序演示如何使用 SqlBulkCopy 类加载数据。在此示例中,使用 SqlDataReader 将数据SQL Server 2005 AdventureWorks 数据库中的 Production.Product 表复制到同一数据库中的相似表。 重要说明: 在您按照批量复制示例设置 (ADO.NET) 中的描述创建工作表之后,此示例才会运行。提供此代码仅为了演示使用 SqlBulkCopy 的语法。如果源表和目标表都在同一个 SQL Server 实例中,则使用 Transact-SQL INSERT … SELECT 语句复制数据会更方便快捷。 using System.Data.SqlClient; class Program { static void Main() { string connectionString = GetConnectionString(); // Open a sourceConnection to the AdventureWorks database. using (SqlConnection sourceConnection = new SqlConnection(connectionString)) { sourceConnection.Open(); // Perform an initial count on the destination table. SqlCommand commandRowCount = new SqlCommand( "SELECT COUNT(*) FROM " + "dbo.BulkCopyDemoMatchingColumns;", sourceConnection); long countStart = System.Convert.ToInt32( commandRowCount.ExecuteScalar()); Console.WriteLine("Starting row count = {0}", countStart); // Get data from the source table as a SqlDataReader. SqlCommand commandSourceData = new SqlCommand( "SELECT ProductID, Name, " + "ProductNumber " + "FROM Production.Product;", sourceConnection); SqlDataReader reader = commandSourceData.ExecuteReader(); // Open the destination connection. In the real world you would // not use SqlBulkCopy to move data from one table to the other // in the same database. This is for demonstration purposes only. using (SqlConnection destinationConnection = new SqlConnection(connectionString)) { destinationConnection.Open(); // Set up the bulk copy object. // Note that the column positions in the source // data reader match the column positions in // the destination table so there is no need to // map columns. using (SqlBulkCopy bulkCopy = new SqlBulkCopy(destinationConnection)) { bulkCopy.DestinationTableName = "dbo.BulkCopyDemoMatchingColumns"; try { // Write from the source to the destination. bulkCopy.WriteToServer(reader); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { // Close the SqlDataReader. The SqlBulkCopy // object is automatically closed at the end // of the using block. reader.Close(); } } // Perform a final count on the destination // table to see how many rows were added. long countEnd = System.Convert.ToInt32( commandRowCount.ExecuteScalar()); Console.WriteLine("Ending row count = {0}", countEnd); Console.WriteLine("{0} rows were added.", countEnd - countStart); Console.WriteLine("Press Enter to finish."); Console.ReadLine(); } } } private static string GetConnectionString() // To avoid storing the sourceConnection string in your code, // you can retrieve it from a configuration file. { return "Data Source=(local); " + " Integrated Security=true;" + "Initial Catalog=AdventureWorks;"; } }

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧