I have almost finished a site that I've been working on but have one last thing that I don't know where to add. I have a bulk insert sql query that I want to insert into the .vb code behind and have no idea where to put it. Basically, the code is attached to a serverclick event that's to be triggered when a user clicks a submit button. Here is the .vb file as it is currently configured:Partial Class _Default Inherits System.Web.UI.Page Private Sub Submit1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit1.ServerClick If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName) Dim SaveLocation As String = Server.MapPath("Data") & "\" & fn Try File1.PostedFile.SaveAs(SaveLocation) Response.Write(<center>Thank you for your submission.</center>) Dim connection As String = ConfigurationManager.ConnectionStrings("Dialerresults").ConnectionString Catch Exc As Exception Response.Write("Error: " & Exc.Message) End Try Else Response.Write(<center>Please select a file to upload.</center>) End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End SubEnd Class
here is the sql bulk insert (please note that I won't need to create a new table as the table is already inserted. This sql query has been tested for the purposes of what I'm trying to do and works, so I need this query inserted into the .vb code behind)bulk insert dialerresultsfrom '\\MSBWEB3\data\test.txt'WITH(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')Select * from dialerresultsgo
I'm assuming that this goes after the TRY statement but as I'm still learning asp.net, I have no idea how to call the command. Any assistance would be helpful.Thank you