Hi, i am getting error Line 1: Incorrect syntax near 'Valuesstuntto'. and its an sql error.Can anyone help me with this thanks.

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using GermanDict;
using SimpleFrenchDict;
using System.Web;




 namespace DicttoData
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }




        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection cn = new SqlConnection(@"Server=server;Database=RTLUser;UID=sa;");
            DataSet CustomersDataSet = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommandBuilder cmdBuilder;
            string myString;
            DataSet ds = new DataSet();
            //cn.ConnectionString = "Server=server;Database=RTLUser;UID=sa;";
            cn.Open();
            GermanDict.DictList ins = new GermanDict.DictList();
            
            Hashtable aaa = ins.AllWords;
            StringBuilder insertCommand = new StringBuilder();
            IDictionaryEnumerator en = aaa.GetEnumerator();
            if (aaa.Count > 0)
            {
                
                while (en.MoveNext())
          
                {
                    ArrayList al = (ArrayList)en.Value;
                    
                        for (int i = 0; i < al.Count; i++)
                        {
                            
                            myString = @"INSERT INTO germanTbl (word,definition)Values"+en.Key + al[i]; 
                             SqlCommand myCmd = new SqlCommand(myString,cn);
                             myCmd.ExecuteNonQuery();

                            
                          
                            
                      }
              
                    
                    
                }
                
            }
            
            cn.Close();
        } 
            
        
    }
}

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Firstly, in future please use code tags.

Secondly, the "VALUES" section of your SQL Statement needs to be enclosed by parenthesis also. You haven't used any. INSERT INTO MyTable(Id, Name) VALUES(12, 'BoB')

Edited 6 Years Ago by Ketsuekiame: n/a

myString = @"INSERT INTO germanTbl (word,definition)Values"+en.Key + al;

than concatinated part of the query are my values so you are saying it should be like

myString = @"INSERT INTO germanTbl (word,definition) Values ("+'en.Key'" + "'al'";

now my insert statement is like
myString = @"INSERT INTO germanTbl (word,definition) Values('" + en.Key + "','" + al + "')";
this did helped me a little but now i am getting error

Line 1: Incorrect syntax near 're'.

Thanks for all the help .

one more last question how can you include you're in a cloumn so that sql statement doesnt think that these are 2 words or missing a "'".
Thanks

one more last question how can you include "you're" in a cloumn so that sql statement doesnt think that these are 2 words or missing a "'".
Thanks

You will need to use double quotes in your string "\"" will output a single "

Also, please stop PM'ing me or I will stop responding. Just because you don't get an immediate response doesn't mean I'm not watching the thread. I have a job to do myself as well you know :P

This question has already been answered. Start a new discussion instead.