Click here to Skip to main content
15,918,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading/Delegate Freezes my App Pin
Judah Gabriel Himango3-Dec-06 12:31
sponsorJudah Gabriel Himango3-Dec-06 12:31 
AnswerRe: Threading/Delegate Freezes my App Pin
S. Senthil Kumar4-Dec-06 4:16
S. Senthil Kumar4-Dec-06 4:16 
Questionlock touchpad Pin
DarsVaeda3-Dec-06 11:51
DarsVaeda3-Dec-06 11:51 
AnswerRe: lock touchpad Pin
logoto_it3-Dec-06 16:37
logoto_it3-Dec-06 16:37 
AnswerRe: lock touchpad Pin
Christian Graus3-Dec-06 17:59
protectorChristian Graus3-Dec-06 17:59 
GeneralRe: lock touchpad Pin
Dan Neely4-Dec-06 2:12
Dan Neely4-Dec-06 2:12 
GeneralRe: lock touchpad Pin
DarsVaeda4-Dec-06 12:04
DarsVaeda4-Dec-06 12:04 
QuestionChanging the datatype of strings Pin
minnie mouse3-Dec-06 11:37
minnie mouse3-Dec-06 11:37 
AnswerRe: Changing the datatype of strings Pin
Christian Graus3-Dec-06 11:52
protectorChristian Graus3-Dec-06 11:52 
GeneralRe: Changing the datatype of strings Pin
minnie mouse3-Dec-06 12:06
minnie mouse3-Dec-06 12:06 
GeneralRe: Changing the datatype of strings Pin
kourvoisier3-Dec-06 12:25
kourvoisier3-Dec-06 12:25 
GeneralRe: Changing the datatype of strings Pin
minnie mouse4-Dec-06 21:18
minnie mouse4-Dec-06 21:18 
GeneralRe: Changing the datatype of strings Pin
Christian Graus3-Dec-06 12:35
protectorChristian Graus3-Dec-06 12:35 
GeneralRe: Changing the datatype of strings Pin
minnie mouse4-Dec-06 11:33
minnie mouse4-Dec-06 11:33 
GeneralRe: Changing the datatype of strings Pin
Christian Graus4-Dec-06 11:39
protectorChristian Graus4-Dec-06 11:39 
GeneralRe: Changing the datatype of strings Pin
minnie mouse4-Dec-06 21:13
minnie mouse4-Dec-06 21:13 
AnswerRe: Changing the datatype of strings Pin
KeesVer4-Dec-06 1:11
KeesVer4-Dec-06 1:11 
QuestionMenu Events Pin
Mark F.3-Dec-06 9:48
Mark F.3-Dec-06 9:48 
AnswerRe: Menu Events Pin
mav.northwind3-Dec-06 10:09
mav.northwind3-Dec-06 10:09 
Questionsearch in access database Pin
suma123823-Dec-06 7:27
suma123823-Dec-06 7:27 
QuestionSynchronized in C# Pin
gaotter3-Dec-06 6:30
gaotter3-Dec-06 6:30 
AnswerRe: Synchronized in C# Pin
Nader Elshehabi3-Dec-06 8:20
Nader Elshehabi3-Dec-06 8:20 
AnswerRe: Synchronized in C# Pin
Judah Gabriel Himango3-Dec-06 12:24
sponsorJudah Gabriel Himango3-Dec-06 12:24 
QuestionSyntax error in INSERT INTO statement. Pin
VirtualG3-Dec-06 5:54
VirtualG3-Dec-06 5:54 
Hi all,

I'm very new to programming in C# (and programming in general). I'm getting "Syntax error in INSERT INTO statement." and I haven't got a clue why.

Here's the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;

namespace dbTest
{
    public partial class Form1 : Form
    {
        String conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Temp\MasterInventory2.mdb";
        OleDbConnection con = new OleDbConnection();
        DataTable dtCardlist = new DataTable();
        DataTable dtTemp = new DataTable();
        OleDbDataAdapter daCardlist;

        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            //Get the data from MasterInventory into my datagridview.
            con.ConnectionString = conString;
            daCardlist = new OleDbDataAdapter("Select * From Cardlist", con);
            daCardlist.Fill(dtCardlist);
            dataGridView1.DataSource = dtCardlist;           
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //1. the InsertCommand
            con.Open();
            daCardlist.InsertCommand = con.CreateCommand();
            daCardlist.InsertCommand.CommandText = "INSERT INTO Cardlist "+
                "(Name, Set, Cost, Type, PowTgh, Rules, Rarity) "+
                "VALUES "+
                "(?,?,?,?,?,?,?)";
            daCardlist.InsertCommand.Connection = con;
            daCardlist.InsertCommand.Parameters.Add("Name", OleDbType.Char, 0, "Name");
            daCardlist.InsertCommand.Parameters.Add("Set", OleDbType.Char, 0, "Set");
            daCardlist.InsertCommand.Parameters.Add("Cost", OleDbType.Char, 0, "Cost");
            daCardlist.InsertCommand.Parameters.Add("Type", OleDbType.Char, 0, "Type");
            daCardlist.InsertCommand.Parameters.Add("PowTgh", OleDbType.Char, 0, "PowTgh");
            daCardlist.InsertCommand.Parameters.Add("Rules", OleDbType.Char, 0, "Rules");
            daCardlist.InsertCommand.Parameters.Add("Rarity", OleDbType.Char, 0, "Rarity");

            //1.1 Test the Insert command
            DataRow newRow = dtCardlist.NewRow();
            newRow["Name"] = "testCard2";
            newRow["Set"] = "TST";
            newRow["Cost"] = "Cost";
            newRow["Type"] = "Type";
            newRow["PowTgh"] = "PowTgh";
            newRow["Rules"] = "Rules";
            newRow["Rarity"] = "Rarity";

            dtCardlist.Rows.Add(newRow);
            daCardlist.Update(dtCardlist);
            con.Close();
            
            /*
            //WORKING VERSION USING MASTERINVENTORY.MDB  
            con.Open();
            daCardlist.InsertCommand = con.CreateCommand();
            daCardlist.InsertCommand.CommandText = "INSERT INTO Cardlist (Name, Cost, Type) VALUES (?,?,?)";
            daCardlist.InsertCommand.Connection = con;
            daCardlist.InsertCommand.Parameters.Add("Name", OleDbType.Char, 0, "Name");
            daCardlist.InsertCommand.Parameters.Add("Cost", OleDbType.Char, 0, "Cost");
            daCardlist.InsertCommand.Parameters.Add("Type", OleDbType.Char, 0, "Type");
            
            //1.1 Test the Insert command
            DataRow newRow = dtCardlist.NewRow();
            newRow["Name"] = "testCard3";
            newRow["Cost"] = "Cost";
            newRow["Type"] = "Type";

            dtCardlist.Rows.Add(newRow);
            daCardlist.Update(dtCardlist);
            con.Close();
            */

       }

    }
}


I suspect that it's something really simple, but I just don't see it. Sigh | :sigh:
Any help is appreciated.
AnswerRe: Syntax error in INSERT INTO statement. Pin
Guffa3-Dec-06 7:28
Guffa3-Dec-06 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.