I'm trying to fill a class with data from a SQL Server table.
I've done the exact thing before using Java for another application (see below)
public LanguageList getSystemLanguages() throws SQLException
{
String sql;
LanguageList language;
sql = "Select DISTINCT code_language From CODE";
prest = conn.prepareStatement(sql);
rset = prest.executeQuery();
language = new LanguageList(rset);
return language;
}
In C# I have so far:
public Incident GetIncidentViaLogID(String LogID)
{
Incident incident;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM dbo.Incident WHERE LogID = @LogID";
cmd.Connection = conn;
SqlParameter p1 = cmd.Parameters.Add("@LogID", SqlDbType.VarChar);
p1.Value = LogID;
p1.Size = -1;
cmd.Prepare();
//Load data into class
}
I've tried numerous things to finish off this method but none have worked. What would be the approach to complete this method?
Thanks!