1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
String conString = "Data Source={SERVER};Initial Catalog={DATENBANK};User Id={USER};Password=
{PASSWORT};MultipleActiveResultSets=true;";
using (SqlConnection con = new SqlConnection(ConString)
{
con.Open();
String sql = "select {FELD1}, {FELD2} from {TABELLE} where {FELD3} = @p1";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@p1", {WERT_FÜR_FELD3});
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
//Tu was wie:
if (!reader.IsDBNull(0))
{
result = reader.GetString(0);
}
}
}
}
|