'var'是VB.NET中的保留字吗?

时间:2017-03-05 21:22:19

标签: vb.net

在下面运行以下代码时,我收到以下错误:

未定义类型'var'。

'var'是VB.NET中的保留字吗?

如果没有,为什么我会收到此错误,如何解决?

<WebMethod()> _
Public Shared Function SaveData(empdata As String) As String
    Dim serializeData = JsonConvert.DeserializeObject(Of List(Of Employee))(empdata)
    Using con = New SqlConnection(Constr)
        For Each data As var In serializeData
            Using cmd = New SqlCommand("INSERT INTO Employees VALUES(@Fname, @Lname,@Email,@CreatedDate)")

                cmd.CommandType = CommandType.Text
                cmd.Parameters.AddWithValue("@Fname", data.FName)
                cmd.Parameters.AddWithValue("@Lname", data.LName)
                cmd.Parameters.AddWithValue("@Email", data.EmailId)
                cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now)
                cmd.Connection = con
                If con.State = ConnectionState.Closed Then
                    con.Open()
                End If
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        Next
    End Using
    Return Nothing
End Function

“更新:

    function getAllEmpData() {
        var data = [];
        $('tr.data-contact-person').each(function () {
            var firstName = $(this).find('.spousename01').val();
            var lastName = $(this).find('.spouseaddress01').val();
            var emailId = $(this).find('.spouseincome01').val();
            var alldata = {
                'FName': firstName,
                'LName': lastName,
                'EmailId': emailId
            }
            data.push(alldata);
        });
        console.log(data);
        return data;
    }

    $("#btnSubmit").click(function () {
        var data = JSON.stringify(getAllEmpData());
        //console.log(data);
        $.ajax({
            url: 'closures.aspx/SaveData',
            type: 'POST',
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify({ 'empdata': data }),
            success: function () {
                alert("Data Added Successfully");
            },
            error: function () {
                alert("Error while inserting data");
            }
        });
    });

0 个答案:

没有答案