English 中文(简体)
在使用OlegDb进入时出现的协同效应
原标题:Syntax error when Insert to Access using OleDb

我在vb.net上没有很多经验,但我试图利用OlegDB在Sting、string、Yes/no(姓名、号码、性别)上添加一个记录。 然而,当我加入时,有人提出例外,说我对“插入”的 que子是无效的。 我无法发现这一错误。

试验:

txtName.Text = "asdasdasd"
txtPhone.Text = "123456789"
rGender.Checked = True

该法典:

    cmd = New OleDbCommand()
    With cmd
        .Connection = cn
        .CommandText = "INSERT INTO [Student] (StudentName, Number, Gender) VALUES(@Name,@Number,@Gender)"
        .CommandType = CommandType.Text
        .Parameters.AddWithValue("@Name", txtName.Text)
        .Parameters.AddWithValue("@Number", txtPhone.Text)
        .Parameters.AddWithValue("@Gender", rGender.Checked)
    End With
最佳回答

Seems such as the Problem with field name “Number”, its a keyword inMSAccess -

问题回答

页: 1

INSERT INTO [Student] ([StudentName], [Number], [Gender]) VALUES(@Name,@Number,@Gender)




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签