TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mohit gupta
NA
145
59.5k
how to use multiple database connection?
Sep 28 2013 2:21 AM
hello
I m using multiple database name in master page?It is not working?single database only working?my code is it..
C#.. private void connection( string str)
{
string strcon = ConfigurationManager.ConnectionStrings["Pcon"].ToString();
SqlConnection con = new SqlConnection(strcon);
String select = txtComand.Text.ToString();
SqlCommand cmd = new SqlCommand(select, con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void run_save(object sender, EventArgs e)
{
string s;
if (button1WasClicked)
{
connection(s);
}
else
{
label1.Text = "invalid value";
}
}
protected void btnPayrol_Click(object sender, EventArgs e)
{
button1WasClicked = true;
}
protected void btnSale_Click(object sender, EventArgs e)
{
button1WasClicked = true;
}
protected void btnsaleE_Click(object sender, EventArgs e)
{
}
protected void btnFinace_Click(object sender, EventArgs e)
{
}
master..
<td><asp:Button id="btnPayrol" runat="server" Text="Payrol"
onclick="btnPayrol_Click" />
</td>
<td><asp:Button id="btnSale" runat="server" Text="Sale"
OnClientClick="window.open('Sale.aspx','Sale.aspx');" onclick="btnSale_Click" /></td>
<td><asp:Button id="btnsaleE" runat="server" Text="ExportSale"
OnClientClick="window.open('SalesE.aspx','SalesE.aspx');"
onclick="btnsaleE_Click" /></td>
<td><asp:Button id="btnFinace" runat="server" Text="Finace" OnClientClick="window.open('Finace.aspx','Finace.aspx');"/></td>
</tr>
<tr><td>
<asp:TextBox runat="server" ID="txtComand" TextMode="MultiLine" Height="227px"
Width="352px"></asp:TextBox>
</td>
<td>
</td>
</tr>
</table>
<asp:Button runat="server" ID="idRun" OnClick="run_save" Text="RUN" />
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
webconfig...<connectionStrings>
<add name="Pcon" connectionString="data source= ITSW2;user id=sa;password=sqliil; initial catalog=payroll;"/>
<add name="Fcon" connectionString="data source= ITSW2;user id=sa;password=sqliil; initial catalog=Finance;"/>
<add name="Vcon" connectionString="data source= ITSW2;user id=sa;password=sqliil; initial catalog=sample;"/>
<add name="Econ" connectionString="data source= ITSW2;user id=sa;password=sqliil; initial catalog=Export_Billing;"/>
</connectionStrings
Reply
Answers (
2
)
MVC
How do i bring CheckBox in to GridView in C#