Unable to retrieve data in asp.net

Posted by Pcjoshi under ASP.NET on 9/18/2012 | Points: 10 | Views : 840 | Status : [Member] | Replies : 4
hello.............
insert into [database1].dbo. [EMAIL_LIST](EMAIL,STATUS,SUBSCRIPTION,BOUNCED,SOURCE,CREATED_BY,CREATED_DATE,MODIFIED_BY, MODIFIED_DATE) select Email_Id,'ACTIVE','','','mftracker','pj',getdate() ,'','' from [database2].dbo.[users]
when i use this query in sql its working properly but when i use this command in asp.net its gives error in users.
can u tell me how i solved it.




Responses

Posted by: Kotra.Ramakrishna on: 9/18/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Please try blow code. Please make sure your connection string correct (your connected same database & server name username& pwd)

string query = "insert into [database1].dbo. [EMAIL_LIST](EMAIL,STATUS,SUBSCRIPTION,BOUNCED,SOURCE,CREATED_BY,CREATED_DATE,MODIFIED_BY, MODIFIED_DATE) select Email_Id,'ACTIVE','','','mftracker','pj',getdate() ,'','' from [database2].dbo.[users] ";

SqlConnection con = new SqlConnection("your connection string")
SqlCommand cmd=new SqlCommand (query,con);
if(con.State!=ConnectionState.Open)
con.Open();
cmd.ExecuteNonQuery();

run this code. Still your getting error? then give me error details.

Thanks & Regards
Ramakrishna.k

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

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

Up
0
Down
string query = "insert into [MAIL@e-wayz].dbo. [EMAIL_LIST](EMAIL,STATUS,SUBSCRIPTION,BOUNCED,SOURCE,CREATED_BY,CREATED_DATE,MODIFIED_BY, MODIFIED_DATE) select '" +TextBox3.Text + "','ACTIVE','','','" + TextBox1.Text + "','" + TextBox4.Text + "',getdate() ,'','' from [MFtracker].dbo.[users] ";
SqlConnection con2 = new SqlConnection("server=173.201.176.161;database=MFtracker;uid=sa;password=Server@1");
SqlCommand cmd=new SqlCommand (query,con2);
if(con2.State!=ConnectionState.Open)
con2.Open();
cmd.ExecuteNonQuery();
i have taken 4 text box i will inter value in text box manually . your code is working but i want to insert data manually .

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

Posted by: Jayakumars on: 9/18/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

mention your table only

select Email_Id,'ACTIVE','','','mftracker','pj',getdate() ,'','' from users



Mark as Answer if its helpful to you

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

Posted by: Kianurieves on: 9/19/2012 [Member] Starter | Points: 25

Up
0
Down
dr.HasRows is just a property that tells you if the datareader contains rows... which if it does will keep having rows from here until eternity. For instance, you would use this if you wanted to do something in the event it has rows and something else in the event it doesn't:
http://www.dapfor.com/en/net-suite/net-grid/tutorial/data-types


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

Login to post response