kindly solve this problem....

Posted by Arunamalraj under DotNetFunda.Com on 5/28/2012 | Points: 10 | Views : 1661 | Status : [Member] | Replies : 2
i am trying to store the csv file into the sql server database using asp dot net.
but i got this error . so kindly correct error and show to me.

Error 1 The type or namespace name 'SteamReader' could not be found (are you missing a using directive or an assembly reference?) D:\testforcsvfile\Default.aspx.cs 26 9 D:\testforcsvfile\
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnimport_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString=("Data source=ARUNAMALRAJ-PC;Intial catalog=csvtest;user id=sa;password=root");
con.Open();
SteamReader sr = new SteamReader("D:\test.csv");
string line;
string SQL="insert into[data1]([[name],[age])values(@name,@age)";
while((line=sr.ReadLine())!=null)
{
SqlCommand cmd = new SqlCommand(SQL,con);
cmd.Parameters.AddWithValue("@name",line[0]);
cmd.Parameters.AddWithValue("@age", line[1]);
cmd.ExecuteNonQuery();
}
con.Close();


}
}




Responses

Posted by: Denny on: 5/28/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Itz not SteamReader..
itz StreamReader..
If you are using Visual Studio,YUou would have got Intellisense working..

Regards,
Denny Kurian

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

Posted by: Arunamalraj on: 5/28/2012 [Member] Starter | Points: 25

Up
0
Down
i did some mistakes.....i will correct and send this website

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

Login to post response