Last post Dec 11, 2010 11:18 PM by suneeld
Jun 14, 2010 12:06 AM|SidC|LINK
I am writing a series of WSS/MOSS webparts amongst which one will need to detect the current SQL Server database connection, prompt the user to setup a new connectionstring, and fire appropriate stored procedures to create a new database if needed.
The user needs to be presented a textbox or label control with the current database connection. I've never had to detect current database connection, what methods do I call for this? If the desirable connection is not present, the web application needs
to prompt the user to make a new database. The user really won't make the database, they simply need to click the command button which will fire the stored procedure to create the database.
Please advise this noob on how to do this in a 3.5 webpart. Thanks much for your help and guidance!
Dec 11, 2010 11:18 PM|suneeld|LINK
Connect to the database using given connection sting. If connection is successful the run this query
select * from sys.databases where name='databasename'. If you get the result back then it means that database exist otherwise you can prompt the user to create it.