.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 8th, 2004, 08:17 PM
crazymouth crazymouth is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 crazymouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem with SQL Insert in .NET

Hi

I have a problem.
I am trying insert each record from a table in a database into a
textfile in sepearte lines .
When I executed the below code,all records except the last 3 records are geting inserted.

when I replace tw.WriteLine(..) witth Console.writeline,I am able to see all records.
But in the text file ,the last 3 are missing.

please help

thanks
Code:
class Class1
{
string Fname="*******";

string source = "server=*****;" +

"uid=*****;pwd=****;" + 

"database=***";

public void Read_Records()

{

TextWriter tw=new StreamWriter("temp.out");

SqlConnection conn=new SqlConnection(source);

try {

conn.Open();

Console.WriteLine("Connection Successful!");

}

catch (Exception e)

{

Console.WriteLine("Connection Failed" + e.Message);

return;

}

try

{

string select="SELECT * FROM M**************;

SqlDataAdapter sda=new SqlDataAdapter(select,conn);

DataSet ds=new DataSet("MEMBER_REQUEST");

sda.Fill(ds);

int Seq_No=1;

if(ds!=null)

{

DataTable dt=new DataTable();

dt=ds.Tables[0];

string Bc="NULL";

foreach(DataRow dr in dt.Rows)

{



string data=Seq_No + "|" +

dr["G_ID"].ToString() + "|" +

dr["ODE"].ToString() + "|" +

dr["T_ID"].ToString() + "|" +

dr["a_DATE"].ToString() + "|" +

dr["VEL"].ToString() + "|" +

dr["ION"].ToString() + "|" +

dr["AR"].ToString() + "|" +

dr["PE"].ToString() + "|" +

dr["ID"].ToString() + "|" +

dr["al1"].ToString() + "|" +

dr["al2"].ToString() + "|" +

dr["al3"].ToString() + "|" +

dr["side"].ToString() + "|" +

dr["efix"].ToString() + "|" +

dr["ae"].ToString() + "|" +

dr["Mnial"].ToString() + "|" +

dr["Lm"].ToString() + "|" +

dr["ufix"].ToString() + "|" +

dr["fx2"].ToString() + "|" +

dr["me2"].ToString() + "|" +

dr["tial2"].ToString() + "|" +

dr["na2"].ToString() + "|" +

dr["fix2"].ToString() + "|" +

dr["A1"].ToString() + "|" +

dr["Axra2"].ToString() + "|" +

dr["Ar1"].ToString() + "|" +

dr["A"].ToString() + "|" +

dr["C"].ToString() + "|" +

dr["S"].ToString() + "|" +

dr["Z"].ToString() + "|" +

dr["Country"].ToString() + "|" +

dr["ZCODE"].ToString() + "|" +

dr["K"].ToString() + "|" +

dr["B"].ToString() + "|" +

dr["F"].ToString() + "|" +

Bc + "|" +

dr["Pack_Id"].ToString();

tw.WriteLine(data);

Seq_No+=1;



}

}

else

{

Console.WriteLine("No Data Returned into the Dataset. ");
}

conn.Close();
}

catch(Exception de)

{

Console.WriteLine("SQL Exception while reading Data " + de.Message);

}

}

[STAThread]

staticvoid Main(string[] args)

{

Class1 c=new Class1();

c.Read_Records();
}
}
}

Last edited by stumpy : April 9th, 2004 at 01:02 AM. Reason: Placed code in CODE tags

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Problem with SQL Insert in .NET


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT