如何在运行时选择数据库。 [英] How do I select database at runtime.

查看:77
本文介绍了如何在运行时选择数据库。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我从第一页选择下拉列表中的数据库,然后通过会话变量发送到第二页。我正在生成运行时连接字符串,因为我有多个数据库。这次我能够检索数据库。并通过c#代码执行存储过程。当我点击按钮第二次查询/ SP.null值来自会话变量。

请建议我....



谢谢,

Rajnikant



我的尝试:



我试过Session,静态变量

Hi All,

I am selecting database in dropdownlist from first page and sending to the second page by session variable.I'm generating runtime connectionstring because i have multiple database. this time i'm able to retrieve the database. and execute stored procedure by c# code. when i click button 2nd time for query/SP.null value comes in session variable.
Please suggest me....

Thanks,
Rajnikant

What I have tried:

I tried Session,static variable

推荐答案

除非你打电话给会员价值

Session value does not get unless you call
Session.clear(); //[it just clear value not make it null]
Session.Abandon();
Session["sessionname"] = null;



请分享您的代码,以便我们更好地帮助您解决问题


Please share your code so that we can help you better in order to resolve your issue


create public第一页中的静态类,如下所示

create public static class in firstpage ,like this
public static class logininfo
       {
           public static string userid;
       }

并且使用获取数据

public string send
       {
           get
           {
               return logininfo.userid;
           }
       }



并在第二页中使用该数据


and use that data in secondpage


在第二页中使用页面

use this in second page
private login pay;



这用于rertive方法


and this used in rertive method

var pay = new login();
            pay.Show();



喜欢这个


like this

label1.Text = "welcome '" + pay.send + "'";


这篇关于如何在运行时选择数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆