其他信息:无效的对象名称'信息' vb.net

时间:2014-09-25 15:04:05

标签: vb.net

请帮助建议我刚开始写作

我正在使用SQL Server Management Studio 2012 表名是dbo.info

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

    Dim SQLCon As New SqlConnection("Data Source=SECURITY;Integrated Security=False;User ID=sa;Password=Rapoo;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False")
    Dim cmd As New SqlCommand

    Private Sub btmSave_Click(sender As Object, e As EventArgs) Handles btmSave.Click
        If txtStaff.Text <> "" And txtName.Text <> "" Then
            SQLCon.Open()
            cmd.CommandText = "insert into info (Club,Staff,Name,Age,Gender,Mobile,Mail,Remark) values ('" & lblClub.Text & "','" & txtStaff.Text & "','" & txtName.Text & "','" & txtAge.Text & "','" & txtGender.Text & "','" & txtMobile.Text & "','" & txtMail.Text & "','" & txtRemark.Text & "')"
            cmd.ExecuteNonQuery()
            SQLCon.Close()

        End If
        Clear()
    End Sub

错误是

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: Invalid object name 'info'.

1 个答案:

答案 0 :(得分:0)

在您的连接字符串中缺少部分
数据库= yourDatabaseName;

初始目录= yourDatabaseName;

如果没有此键,您的查询将对没有INFO

的MASTER数据库执行