通过查询字符串查询数据库 [英] Query a database through query string

查看:131
本文介绍了通过查询字符串查询数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想创建一个http://localhost/menu.aspx/?id之类的URL,以便在地址栏中键入该URL时,它会显示数据库中的所有id.例如:
134
123
543
234
可能是从数据库中获取的ID,应在上述URL上如上显示.

这些应该按原样显示,没有任何控制或没有安排在任何网格等中.我知道如何查询db以获取ID,但是如何在URL http://localhost/menu.aspx/?id

Hi,

I wanted to create a URL like http://localhost/menu.aspx/?id so that on typing this in the address bar, it displays all the id''s in the database. for eg:
134
123
543
234
may be the id''s fetched from the DB which should be displayed as above on the above URL.

These should be displayed as it it is without any control or without arranging in any grid etc. I know how to query the db for the Id''s but how do I display them on the webpage on this URL http://localhost/menu.aspx/?id

推荐答案

从外观上看,该URL:http://localhost/menu.aspx/?id并没有多大意义,并且将忽略"id".这不是有效的查询字符串.

您可以做的是:使用"URL重写" .
在此处阅读:使用ASP.NET进行URL重写 [ MSDN:URL重写 [ URL路由 [
Visually, this url: http://localhost/menu.aspx/?id, does not make much sense and the ''id'' would be ignored. It''s not a valid query string.

What you can do is: Use ''URL Rewriting''.
Read here: URL Rewriting with ASP.NET[^]
MSDN: URL Rewriting[^]
OR
Read about, In ASP.NET 4.0: URL Routing[^]

Internally, you can formulate a URL that would do the same thing that you want. Infact, you can also handle the same URL that you want. Once URL rewriting is in place you can handle the URL accordingly and display the data desired.


这篇关于通过查询字符串查询数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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