Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

grabbing one value from a table

0 views
Skip to first unread message

ArkyTec

unread,
Jun 20, 2002, 11:58:31 PM6/20/02
to
Hi, how would i take one cell from an access table, and put it into a
variable... this is using C#. Would i use a dataadapter or what? TIA

-NF

Jeff Louie

unread,
Jun 21, 2002, 2:39:44 AM6/21/02
to
Arky...
Check out SqlCommand.ExecuteScalar().

string myScalarQuery= "SELECT au_lname FROM Authors WHERE au_id =
'111-11-11111'";

public void CreateMySqlCommand(string myScalarQuery, SqlConnection
myConnection)
{
SqlCommand myCommand = new SqlCommand(myScalarQuery, myConnection);
myCommand.Connection.Open();
string temp= myCommand.ExecuteScalar().ToString();
myConnection.Close();
}
Jeff


>Hi, how would i take one cell from an access table, and put it into a
variable... <

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

ArkyTec

unread,
Jun 21, 2002, 10:37:01 AM6/21/02
to
On Thu, 20 Jun 2002 23:39:44 -0700, Jeff Louie
<jeff...@compuserve.com> wrote:

OleDbConnection typeConn = new
OleDbConnection(frmMain.connectionString);

typeConn.Open();

OleDbCommand typeCom = new OleDbCommand(String.Format("SELECT
TableType FROM tblBlackCoconutsZing WHERE TableName = {0}",
vocabTable.ToString()), typeConn);

string tableType = typeCom.ExecuteScalar().ToString();

typeConn.Close();

OK, i have this........ it throws an exception on the exe scalar line
"no value given for one or more required parameters"

there aren't any parameters for ExecuteScalar().... so what's going on
here? THanks again

NIA

ArkyTec

unread,
Jun 21, 2002, 10:53:01 AM6/21/02
to
nevermind i got it to work, thanks
0 new messages