请帮助建议我刚开始写作
我正在使用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'.
答案 0 :(得分:0)
在您的连接字符串中缺少部分
的数据库= yourDatabaseName; 强>
或
初始目录= yourDatabaseName;
如果没有此键,您的查询将对没有INFO
表