Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:49:43+00:00 2026-05-26T22:49:43+00:00

I have a form built in webmatrix that will be updating data within a

  • 0

I have a form built in webmatrix that will be updating data within a user specified database.

I would like the user to insert their DB name into the form, and have the Database.Open("SQLServerConnectionString"); open based on the users submission.

if not possible, is there a way to simply include the user specified DB name within the SQL query below within webmatrix? Sample of what I have below:

 var db = Database.Open("SQLServerConnectionString");
 var selectQueryString = "SELECT donor_id,first_name,last_name FROM SUPPORT.dpo.dp WHERE donor_id=@0";

I would like the static “SUPPORT” database in the FROM clause to be updated dynamically based on user input. Any help would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:49:44+00:00Added an answer on May 26, 2026 at 10:49 pm

    Are you using .mdf files or actual database connection strings? If connection strings you can use the OpenConnectionString method and pass a custom connection string instead of using whats in the web.config.

    http://msdn.microsoft.com/en-us/library/gg569301(v=VS.99).aspx

    Something like this would probably work:

    @{ 
        var databaseName = Request["databaseName"]; //load from request
        var connectionString = string.Format("Data Source=.\\SQLExpress;Initial Catalog={0};Integrated Security=True", databaseName);
        var providerName = "System.Data.SqlClient"; 
        var db = Database.OpenConnectionString(connectionString, providerName); 
        var selectQueryString = "SELECT * FROM Product ORDER BY Name"; 
    } 
    

    You can just drop the SUPPORT. prefix as its not necessary for the select statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that is being dynamically built depending on user selection using
I have a Windows Form application built on a data model and a Windows
I'm trying to have the action of a HTML form built when the user
i have bought a template that have built in contact form problem is that
In good old MFC, the DDX routines would have built in validation for form
i have a form that is dynamically built. so the number of form elements
I have a form in my winforms app that acts as a built-in browser.
I have a form which will include some optional questions that need to asked
I have a large form built with twitter's bootstrap kit. The fields look like
I have form which is built like this: <%= form_for @location do |f| %>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.