在数据库中搜索信息
问题描述:
朋友们,
我对使用SQL Server从数据库搜索数据感到困惑.如果有人用C#语言回答了这个问题,请帮助我
Hi friends,
I am confused about searching a data from database using SQL server. if any one have answer of this question in C# language please help me
答
使用带有WHERE子句的SELECT语句:
Use a SELECT statement with a WHERE clause:
using (SqlCommand com = new SqlCommand("SELECT * FROM Customers WHERE CustomerId=102", con))
{
SqlDataReader r = com.ExecuteReader();
while (r.Read())
{
Console.WriteLine("{0}:{1}:{2}", r["Customer"], r["date"], r["Value"]);
}
}
1. GoogleADO.Net C#
.
2.您将获得566万次点击.
3.阅读以上任何内容.
瞧,编程很容易!
1. GoogleADO.Net C#
.
2. You will get 5,660,000 hits.
3. Read any of above.
See, programming is easy!
您提到过,对于从数据库中搜索数据感到困惑,但是您没有提及导致您困惑的原因.如果可以的话,您是否尝试过一些事情,以便您的代码,然后我们将很容易地提出问题.
随便问一个问题,搜索数据"是指根据
这样的条件检索特定属性 *记录符合一个或多个条件的
*包含给定范围内的值的记录
*包含给定值集中的任何值的记录
*与模式匹配的记录
*包含空值的记录
*记录按顺序显示
*表格顶部的记录
*记录中没有重复的值
现在哪个条件符合您的要求
看一下那里-[使用C#检索数据] [
you have mentioned that you are confused about searching data from database but you haven''t mention whats lead you to confusion. have you tried some thing if so please so your code then we will easily justify with question.
whatever, come to your question "searching Data" means retrieving Specific Attributes based on the condition like
* Record that Match one or more conditions
* Records that Contain values in a given range
* Records that contain any value from a given set of values
* Records that match a pattern
* Records that Contain Null values
* Records to be displayed in a sequence
* Records from the top of a table
* Records without duplications of values
Now which condition matching your requirement
Take a look there-[Retrieving Data Using a C# ][^] where you can learn how to search data.