解析查询时出错。 [令牌行号= 1,令牌行偏移= 13,令牌错误=插入] [英] There was an error parsing the query. [ Token line number = 1,Token line offset = 13,Token in error = insert ]

查看:124
本文介绍了解析查询时出错。 [令牌行号= 1,令牌行偏移= 13,令牌错误=插入]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Windows.Forms ;

使用System.Net;

使用System.Net.Mail;

使用System.Net.Mime;

使用System.Data.SqlServerCe;



命名空间WindowsFormsApplication3

{

公共部分类Form1:表格

{

public Form1()

{

InitializeComponent();

}



private void button1_Click(object sender,EventArgs e)

{

try

{

MailMessage mail = new MailMessage();

SmtpClient SmtpServer = new SmtpClient(smtp.gmail.com);





mail.From = new MailAddress(ajay.raturi22@gmail.com);

mail.To.Add(vicky16792@gmail.com);

mail.CC.Add(new MailAddress(sunny.raturi7@gmail.com,Ajay raturi));

mail.Bcc.Add(new MailAddress(shubham14091991 @ gmail) .com,Shubham));

mail.Subject =Test Mail - 1;

mail.Body =带附件的邮件;



//mail.CC.Add(\"ajay.raturi22@gmail.com,Ajay);

//mail.AddCC( Chilkat HR,vicky16792 @ gmail.com);

//mail.AddMultipleCC(new MailAddress(Jack Frost< vicky16792@gmail.com>,Bob< ajay .raturi22 @ gmail.com>));



System.Net.Mail.Attachment附件;

attachment = new System.Net .Mail.Attachment(C://Users/adiuser1/Downloads/Capture.PNG);

m ail.Attachments.Add(附件);



SmtpServer.Port = 587;

SmtpServer.Credentials = new System.Net.NetworkCredential( ajay.raturi22@gmail.com,976079905666);

SmtpServer.EnableSsl = true;



SmtpServer.Send(mail );

MessageBox.Show(邮件发送);

}



catch(Exception ex)

{

Console.WriteLine(ex.ToString());

}

}



private void checkedListBox1_SelectedIndexChanged(object sender,EventArgs e)

{



}





private void button2_Click(object sender,EventArgs e)

{



SqlCeConnection x;

// SqlCeCommand y;

string constr = Properties.Settings.Default.vikasConnectionString;

try

{

x = new SqlCeConnection(constr );

x.Open();

string query =INSERT INTO insert(email,name)values('+ textBox1.Text +',' + textBox2.Text +');

SqlCeCommand myCommand = new SqlCeCommand(query,x);

int result = myCommand.ExecuteNonQuery();



MessageBox.Show(hahahaha);

x.Close();

}

catch(Exception ex)

{

throw ex;

}

} < br $>




private void Form1_Load(object sender,EventArgs e)

{



}

}}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Data.SqlServerCe;

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

private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");


mail.From = new MailAddress("ajay.raturi22@gmail.com");
mail.To.Add("vicky16792@gmail.com");
mail.CC.Add(new MailAddress("sunny.raturi7@gmail.com", "Ajay raturi"));
mail.Bcc.Add(new MailAddress("shubham14091991@gmail.com", "Shubham"));
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";

//mail.CC.Add("ajay.raturi22@gmail.com", "Ajay");
//mail.AddCC("Chilkat HR", "vicky16792@gmail.com");
//mail.AddMultipleCC(new MailAddress(""Jack Frost <vicky16792@gmail.com>", "Bob <ajay.raturi22@gmail.com>"));

System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("C://Users/adiuser1/Downloads/Capture.PNG");
mail.Attachments.Add(attachment);

SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("ajay.raturi22@gmail.com", "976079905666");
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}

catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}


private void button2_Click(object sender, EventArgs e)
{

SqlCeConnection x;
// SqlCeCommand y;
string constr = Properties.Settings.Default.vikasConnectionString;
try
{
x = new SqlCeConnection(constr);
x.Open();
string query="INSERT INTO insert(email,name) values ('" + textBox1.Text + "', '" + textBox2.Text + "')";
SqlCeCommand myCommand = new SqlCeCommand(query, x);
int result=myCommand.ExecuteNonQuery();

MessageBox.Show("hahahaha");
x.Close();
}
catch(Exception ex)
{
throw ex;
}
}


private void Form1_Load(object sender, EventArgs e)
{

}
}}

推荐答案





您使用的查询为:

Hi,

You are using the query as:
string query="INSERT INTO insert(email,name) values ('" + textBox1.Text + "', '" + textBox2.Text + "')";





插入是一个保留字。如果这是你的表名,请使用[Insert]

赞,



Insert is a reserved word. If that is your table name use [Insert]
Like,

string query="INSERT INTO [insert](email,name) values ('" + textBox1.Text + "', '" + textBox2.Text + "')";





如果没有,请检查插入查询中的表名。



希望这有帮助!! :) :)



问候,

Praneet



If not, then check your table name in the insert query.

Hope this helps !! :) :)

Regards,
Praneet


string query="INSERT INTO insert(email,name) values ('" + textBox1.Text + "', '" + textBox2.Text + "')";





你有一个名为'insert'的表吗?真的吗?这是不好的做法 - 正如您可以通过错误看到的,sql语句解析器不喜欢它!



创建一个具有不同名称的表,例如email_raw和再次尝试SQL,例如





you have a table called 'insert' ? really ?? that's bad practice - as you can see by the error, the sql statement parser doesn't like it !!!

create a table with a different name eg email_raw and try the SQL again, eg

string query="INSERT INTO email_raw(email,name) values ('" + textBox1.Text + "', '" + textBox2.Text + "')";





顺便说一句,将SQL放在一起就像是一个坏主意,但是,在我们讨论



btw, putting SQL together like that is also a bad idea, but lets get it going before we cover that


这篇关于解析查询时出错。 [令牌行号= 1,令牌行偏移= 13,令牌错误=插入]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆