我的系统概念是这样的。我完成了使用内连接显示来自不同表的列。
我发现很难,因为我认为您一次只能在 sql 中使用插入命令到一个表。
但我的数据网格显示从不同表调用的不同列。
我的 sql 语法的结构是怎样的?并在 vb.net 2003 上调用存储过程
感谢任何人的任何想法
这是我的 SQL 存储过程
CREATE PROCEDURE AddToOfficeEquipmentProfile AS
INSERT INTO dbo.tblOfficeEquipmentProfile(OE_ID
, Report_ID
, OE_Category
, OE_SubCategory
, OE_Name
, OE_User
, OE_Brand
, OE_Model
, OE_Specs
, OE_SerialNo
, OE_PropertyNo
, OE_Static_IP
, OE_Vendor
, OE_PurchaseDate
, OE_WarrantyInclusiveYear
, OE_WarrantyStatus
, OE_Status
, OE_Dept_Code
, OE_Location_Code
, OE_Remarks)
VALUES
(DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)
GO
这是我的 VB 代码
Dim sqlconn As New SqlClient.SqlConnection
sqlconn.ConnectionString = "server = SKPI-APPS1;" & _
"Database = EOEMS;integrated security=true"
Dim Command As SqlCommand = New SqlCommand
Command.Connection = sqlconn
Command.CommandText = "AddToOfficeEquipmentProfile"
Command.CommandType = CommandType.StoredProcedure
Dim sAdapter As SqlDataAdapter = New SqlDataAdapter(Command)
Dim DataSet As DataSet = New DataSet(Command.CommandText)
sAdapter.Fill(DataSet)
DataGrid1.DataSource = DataSet.Tables(0)
MsgBox(MsgBoxStyle.OKOnly, "YOU HAVE SUCCESSFULLY ADDED RECORDS TO THE TABLE")
它返回指向的错误
sAdapter.Fill(DataSet)
这是我下面的第二个代码,不需要存储过程
Dim adapter As New SqlDataAdapter
Dim sql As String
sql = "INSERT INTO tblOfficeEquipmentProfile(OE_ID, Report_ID, OE_Category, OE_SubCategory, OE_Name, OE_User, OE_Brand, OE_Model, OE_Specs, OE_SerialNo, OE_PropertyNo, OE_Static_IP, OE_Vendor, OE_PurchaseDate, OE_WarrantyInclusiveYear, OE_WarrantyStatus, OE_Status, OE_Dept_Code, OE_Location_Code, OE_Remarks)VALUES(DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)"
Try
sqlconn.Open()
adapter.InsertCommand = New SqlCommand(sql, sqlconn)
adapter.InsertCommand.ExecuteNonQuery()
MsgBox("Row inserted !! ")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
但仍然无法正常工作