Get URL Paramaeters if u r using internal script or referenced script

var url = new URL(‘https://sample.com?a=1&b=2&c=3’).searchParams;
params.get(‘a’); // “1”
params.get(‘b’); // “2”
params.get(‘c’); // “3”

or

var param1=location.search.split(‘a=’)[1]
var param2=location.search.split(‘b=’)[1]
var param3=location.search.split(‘c=’)[1]

Advertisements

Create New DB by Executing Scripts C#

string sqlConnectionString = @”Integrated Security=True;Initial Catalog=master;Data Source=.”; //Reference Connection String
FileInfo File = new FileInfo(Server.MapPath(“/sample.sql”)); // .SQL path
string script = File.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
var db = new Database(server, “sampledb”); // Mention DB Name here i’ve mentioned sampledb as my new DB Name
db.Create();
db.ExecuteNonQuery(script);

Note:

While generating .sql script in db.Follow these steps

DBname –> Tasks –> Generate Scripts –> select specific database objects (check Tables & SP’s) –> Next –>Advanced(Script Use Database = false) –> OK –>Next

it is mandatory to false Script Use Database if u want to create new DB with different name or else it is not required