I have a class that contains all the SQL objects, including how to create a database connection and execute a query Are there. / P>
From another class, I can make an example of that "database" object and execute the query for a query that I want to set during my remaining queries for a connection: < / P> After executing the above, using the same connection, I then execute another query that uses the variable, but I get an error saying this That instituionId should be set. So it appears that once the second query was executed, the previous results were lost. Can I continue the above as well, or should I include declaration and set commands with each query executed? When I do this in Microsoft SQL Server Management Studio, I only need to run it once and it sticks to all queries in my query window, so I thought (uninterrupted probably) the results would stick. Thanks, Jason No, only query scope of query Will be valid for the period. For example, remember that most SQL connections will reuse the drivers from the connection pool, so it will be impossible for SQL and your app to ask which questions are asked from the previous context. The exact requirements of your app, I will add InstitutionID as the member / asset of your database class. After this, the database class is responsible for sending the value of that member as a query parameter on each request: ex. Announcement @InstitutionId NVARCHAR (MAX); SET @InstitutionId = '15 ';
command. Parameter. Add with Value ("@ Institutions", This Institutional ID);
Comments
Post a Comment