/solved
<command>.CommandText = "SELECT Row FROM Table"; string txtNews = Convert.ToString(command.ExecuteScalar()); <richTextBox1>.Text = txtNews;
Don't forget to select a table from your DB.Quote:
So any idea how to get the result to a string?
private string _readStringDB1;
private string _readStringDB2;
private string _readStringDB3;
SqlDataReader reader = Command.ExecuteReader();
while (reader.Read())
{
_readStringDB1 = reader.GetString(0); //First column
_readStringDB2 = reader.GetString(1); //Second column
_readStringDB3 = reader.GetString(2); //Third column
}
ExecuteScalar can only handle one column / cell. If there is multiple value it will take the first column of the first row.Quote:
I am gett ofng "0" as a string
cmd.CommandText = ("Select * FROM _Char");
cmd.Connection = sqlconn.cnn;
string txtNews = Convert.ToString(cmd.ExecuteScalar());
richTextBox1.Text = txtNews;
The result should be like this
There's only 1 row in the table [Only registered and activated users can see links. Click Here To Register...]
Reader just returns the "System.Data.SqlClient.SqlDataReader" as text...Quote:
ExecuteScalar can only handle one column / cell. If there is multiple value it will take the first column of the first row.
Use ExecuteReader instead.
Best approach would be LinQ to SQL: [Only registered and activated users can see links. Click Here To Register...]
SELECT LAST_INSERT_ID()