S
SteveNJ
Hi,
i'm building an application to take a CSV file and tranfer it to a SQL database. Everything works well the way I have it and the data gets posted into the database.
The problem is the data gets inserted TWICE. I have 4 rows in my test CSV file and 8 rows end up in my SQL table. I've looked at the insert statement using the commandText and it looks fine. Below is the code
I'm at a loss here and really need help.
Thanks!!
Dim FilePath As String = Server.MapPath("/qxqrwadmin/upload")
Dim Conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath & ";Extended Properties=""text;HDR=Yes;FMT=Delimited""")
Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from lth.csv", Conn)
Comm.AcceptChangesDuringFill = false
Dim DS As new System.Data.DataSet
ds.HasChanges()
Comm.Fill(ds)
ds.HasChanges()
DataGrid1.DataSource = DS.Tables(0).DefaultView 'Test to see the data being properly selected
DataGrid1.DataBind()
Dim strConnect as string
Dim strSQL as string
strSQL = "Select * from hostingbysc.lthIVRApplications where 1=2"
strConnect = ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_lthASPNET")
Dim objConn As New SQLConnection(strConnect)
Dim objCmd As New System.Data.SQLClient.SQLDataAdapter(strSQL, objConn)
Dim cb As SQLCommandBuilder = New SQLCommandBuilder(ObjCmd)
objCmd.Update(ds)
i'm building an application to take a CSV file and tranfer it to a SQL database. Everything works well the way I have it and the data gets posted into the database.
The problem is the data gets inserted TWICE. I have 4 rows in my test CSV file and 8 rows end up in my SQL table. I've looked at the insert statement using the commandText and it looks fine. Below is the code
I'm at a loss here and really need help.
Thanks!!
Dim FilePath As String = Server.MapPath("/qxqrwadmin/upload")
Dim Conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath & ";Extended Properties=""text;HDR=Yes;FMT=Delimited""")
Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from lth.csv", Conn)
Comm.AcceptChangesDuringFill = false
Dim DS As new System.Data.DataSet
ds.HasChanges()
Comm.Fill(ds)
ds.HasChanges()
DataGrid1.DataSource = DS.Tables(0).DefaultView 'Test to see the data being properly selected
DataGrid1.DataBind()
Dim strConnect as string
Dim strSQL as string
strSQL = "Select * from hostingbysc.lthIVRApplications where 1=2"
strConnect = ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_lthASPNET")
Dim objConn As New SQLConnection(strConnect)
Dim objCmd As New System.Data.SQLClient.SQLDataAdapter(strSQL, objConn)
Dim cb As SQLCommandBuilder = New SQLCommandBuilder(ObjCmd)
objCmd.Update(ds)