I have a MS SQL database with som tables in it. what Iīd like to do is get an ID value from one of the tables to another table. I guess I should be able to do this with ASP.Net(C#), but I canīt get it there.
This is the SQL stmt:
select ActorID from Actor where ActorName = 'Name'
then I want the value of this, which is an int, into an int variable, such as:
int actor_ID;
SqlConnection conn = new SqlConnection(CONNECTION_STRING);
string strSQL = "select ActorID from Actor where ActorName = 'Name'";
SqlCommand cmd = new SqlCommand(strSQL,conn);
int intNumber;
conn.Open();
intNumber = (int) cmd.ExecuteScalar();
conn.Close();
That should be it. Remember to import your System.Data.SqlClient namespace.
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL