English 中文(简体)
添加日期错误
原标题:insert datetime error

I have problem when inserting a date to my database Insert query:

INSERT INTO users (f_name, s_name, t_name,family_name, age, national_id, 
telephone, mobile,  address, job_name, company_code, start_date, end_date)
VALUES (N " + fname + " ,N " + sname + " ,N " + tname + " ,N " + famiy_name + 
        " ,N " + age + " ,N " + national_id + " ,N " + telephone + 
        " ,N " + mobile + " ,N " + address + " ,N " + job_name + " ,N " + 
        company_code + " ," + start_date + "," + end_date + ")";

脚注“N”在条目前插入阿拉伯文

错误信息:

Incorrect syntax near 12 .

虽然文字视器的日期格式是

2010年11月5日

I use VS2010 with theDB sql express 2008

最佳回答

1. 利用参数而不是按类别划分来建立你的询问:

using (SqlCommand myCommand = new SqlCommand(
    "INSERT INTO users (f_name, s_name, ...) VALUES (@f_name, @s_name, ...)")) {

    myCommand.Parameters.AddWithValue("@f_name", f_name);
    myCommand.Parameters.AddWithValue("@s_name", s_name);
    //...

    myConnection.Open();
    myCommand.ExecuteNonQuery())
    //...
}
问题回答

www.un.org/Depts/DGACM/index_spanish.htm 为什么出现这种情况? 它希望你能用单一报价限定你的日期。

www.un.org/Depts/DGACM/index_spanish.htm 您应当做些什么:使用





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签