Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to save records inputted in datagrid to sql database
    text
    copied!<p>my system concept is this. im done displaying columns from different tables using inner join.</p> <p>im finding a hard time because, i think that you can only use insert command in sql to one table at a time.</p> <p>but my datagrid displays different columns called from different table.</p> <p>how would be the structure of my sql syntax be? and also calling the stored procedure on vb.net 2003</p> <p>thanks any ideas anyone</p> <p>THIS IS MY SQL STORED PROC</p> <pre><code>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 </code></pre> <p>THIS IS MY VB CODE</p> <pre><code>Dim sqlconn As New SqlClient.SqlConnection sqlconn.ConnectionString = "server = SKPI-APPS1;" &amp; _ "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") </code></pre> <p>it returns error pointing to </p> <pre><code> sAdapter.Fill(DataSet) </code></pre> <p>HERE IS MY SECOND CODE BELOW WITH NO STORED PROCEDURE NEEDED</p> <pre><code> 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 </code></pre> <p>but still not working</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload