How to store connection string in database table

Posted by Pcjoshi under ASP.NET on 9/14/2012 | Points: 10 | Views : 1820 | Status : [Member] | Replies : 9
Hello,
I have a form their are 3 text boxes and below button first one for connection string second one for table name and last one is column name
when i click button how can i store given connection string in given tables column. please provide me solution.




Responses

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
do u give connection string in that textbox?

Thanks & Regards
Hari

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pcjoshi on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Yes I will provide connection string in text box table name also in text box where i want to store and column name also provide.

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
u can write the code in button click event for saving those values..

Thanks & Regards
Hari

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pcjoshi on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Can u help how i write code.

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
sqlcommand cmd=new sqlcommand("insert into tablename('"+txtconnectionstring.text+"','"+txttablename.text+"'),con);
cmd.executenonquery();
Please try like this.

Thanks & Regards
Hari

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Pcjoshi,
if u satisfied for my answer.Please select Mark As Answer.

Thanks & Regards
Hari

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pcjoshi on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Hariinakoti,
you are getting my question.

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
y u asking like that?

Thanks & Regards
Hari

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnbhatt on: 9/14/2012 [Member] Starter | Points: 25

Up
0
Down
Pcjoshi,

I think, You want to Store Data to Database which are in Front End instead of connection String. If this is the case, Not a Problem.
Write below code in Button Click Event.

{

string Constring = txtBox1.Text;
string TableName = txtBox2.Text;
string ColumnName = txtBox3.Text;
SqlConnection Con = new SqlConnection(Constring.ToString());
SqlDataAdaptor adp = new SqlDataAdaptor("Update table @tblName Set @ColName = '"+txtBox4.Text+"' where id=1",Con);
adp.SelectCommand.CommandType = CommandType.Text;
adp.SelectCommand.Parameters.AddWithValue("@tblName",TableName);
adp.SelectCommand.Parameters.AddWithValue("@ColName",ColumnName);
DataSet ds = new DataSet();
adp.Fill(ds);
}


This code is not Written in any editor. So please make correction in Some case.

John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response