Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8865941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:39:16+00:00 2026-06-14T16:39:16+00:00

I have a C# project where I am trying to autofill a SQL table

  • 0

I have a C# project where I am trying to autofill a SQL table with a file downloaded from the net.

The file is http://ts1.travian.com/map.sql and you will see that it has data already set for SQL database manipulations.

Here’s a little snipet of how they look:

INSERT INTO `x_world`
    VALUES (1517,315,399,3,181705,'New Remial',82126,'Tale',0,'',273);
INSERT INTO `x_world`
    VALUES (67792,107,316,1,175829,'3.Clay',35440,'salvaje_jabali',0,'',244);
INSERT INTO `x_world`
    VALUES (32790,349,360,1,189271,'Lumeria',9702,'Aquifel',90,'APE',20);
INSERT INTO `x_world`
    VALUES (72449,-42,310,1,194313,'New village',2634,'paloc',0,'',24);
INSERT INTO `x_world`
    VALUES (75669,-26,306,1,170802,'Yao Ming',2634,'paloc',0,'',330);

I’ve inserted a break line before each INSERT code for readability.

I have recreated the Table in my project with all the required columns but how can I have the project download the file on the click of a Button (named CommandButton1) and then parse all of that data into the required columns in the table in my project (the data in the downloaded file is separated by a comma it seems all the way through).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:39:18+00:00Added an answer on June 14, 2026 at 4:39 pm

    Using the code from Robbie’s answer and elaborating on that:

    using System.Net;
    
    //Download
    WebClient Client = new WebClient ();
    Client.DownloadFile("http://ts1.travian.com/map.sql", @"C:\folder\file.sql");
    
    // Read into a file
    var sqltext = System.IO.File.ReadAllText(@"c:\folder\file.sql");
    // Split the sql statements up
    var sqlStatements = sqltext.Split(';'); 
    
    // Insert
    using (SqlConnection connection = new SqlConnection(connectionParameters))
        {   
            connection.Open();
            foreach (var sqlStatement in sqlStatements)  
            {
                SqlCommand command = new SqlCommand(sqlStatement, connection);
                command.ExecuteNonQuery();
            }
        }     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project setup and i'm trying to access a file from a
I have created a wpf vb.net project and am trying to set a simple
I have a project where we are trying to skin Spark components from a
I have a project where I am trying to grab text from a uilabel
I have a project whereby I'm trying to create a distribution zip file, which
I have Android project (com.appocaliptic.quizknife.app) which uses Android library (com.appocaliptic.quizknife.core). What I am trying
I have an ASP.Net c# project trying to access methods in a class in
I have a project in python that I am trying to run from IDLE
I have a project that has alot of file manipulation. I am trying out
ASP.NET MVC3 Razor project Trying to implement OpenID using http://weblogs.asp.net/haithamkhedre/archive/2011/03/13/openid-authentication-with-asp-net-mvc3-dotnetopenauth-and-openid-selector.aspx I've edited the openid-en.js

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.