提交信息时如何从数据库中检索表行 [英] how to retrive table rows from database when submit information

查看:61
本文介绍了提交信息时如何从数据库中检索表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在做铁路预订项目,实际上我遇到了麻烦.只是说一些主意.我的后端是SQL Server.

我以asp.net的形式在特定日期提供火车的来源和目的地,然后提交.它应该搜索数据库并显示匹配的火车详细信息

我该怎么做????????

解决方案

在不知道您使用的表等的情况下,不可能给出更确切的答案,但是您的查询可能类似于

  SELECT  Col1,Col2,...
 FROM 时间表tt - 或表名是什么
位置 tt. =  @ SourceCity 
 AND  tt.Destination =  @ DestinationCity 
 AND  tt.DepartureDate =  @ DepartureDate  


所有表名和列名都是虚拟的,因此您必须对其进行修改以适合您的实际数据库架构.

要运行查询,您需要:
- SqlConnection [ SqlCommand [ SqlParameter [ SqlDataAdapter [ 解决方案

Without knowing the tables etc you use, it''s impossible to give more exact answer, but your query could look something like

SELECT Col1, Col2, ...
FROM TimeTable tt -- or whatever is the table name
WHERE tt.Source = @SourceCity
AND   tt.Destination = @DestinationCity
AND   tt.DepartureDate = @DepartureDate


All the table names and column names are fictitious so you have to modify this to be suited against your actual database schema.

To run the query you need:
-
SqlConnection[^]
- SqlCommand[^]
- SqlParameter[^]
- and most likely SqlDataAdapter[^] to fill a datatable for example


这篇关于提交信息时如何从数据库中检索表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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