FYI... I found the solution over the weekend reading the SQL Server Magazine
InstantDoc ID 40791-Listing2.
This solution in not like you suggest as one line code but it works for
me now.
Part of the problem with you suggestion is that I dont have the
invoiceStatus column in my flexgrid and I have to setup this value as zero.
Tks again
JFB
Dim conn As New SqlConnection(connectionString)
Dim insertSQL As String = "INSERT INTO
Orders(customerID,houseID,orderDate,description,em ployeeID,invoiceStatus)val
ues(@customerID,@houseID,@orderDate,@description,@ employeeID,@invoiceStatus)
"
Dim cmd As New SqlCommand(insertSQL, conn)
'Declaring all the input parameters
Dim parmCustomerID = New SqlParameter("@customerID", SqlDbType.Int, 4)
parmCustomerID.direction = ParameterDirection.Input
Dim parmHouseID = New SqlParameter("@houseID", SqlDbType.Int, 4)
parmHouseID.direction = ParameterDirection.Input
Dim parmOrderDate = New SqlParameter("@orderDate", SqlDbType.SmallDateTime,
4)
parmHouseID.direction = ParameterDirection.Input
Dim parmEmployeeID = New SqlParameter("@employeeID", SqlDbType.Int, 4)
parmEmployeeID.direction = ParameterDirection.Input
Dim parmDescription = New SqlParameter("@description", SqlDbType.VarChar,
255)
parmDescription.direction = ParameterDirection.Input
Dim parmInvoiceStatus = New SqlParameter("@invoiceStatus", SqlDbType.Bit, 1)
parmInvoiceStatus.direction = ParameterDirection.Input
'Add the parameter objects to the cmd parameter collection
cmd.Parameters.Add(parmCustomerID)
cmd.Parameters.Add(parmHouseID)
cmd.Parameters.Add(parmOrderDate)
cmd.Parameters.Add(parmEmployeeID)
cmd.Parameters.Add(parmDescription)
cmd.Parameters.Add(parminvoicestatus)
Try
conn.Open()
cmd.Prepare()
Dim i As Integer
For i = 1 To ordersFG.Rows.Count - 2
'Add the values to the parameters
parmCustomerID.value = ordersFG(i, 1)
parmHouseID.Value = ordersFG(i, 2)
parmOrderDate.Value = ordersFG(i, 3)
parmEmployeeID.Value = ordersFG(i, 4)
parmDescription.Value = ordersFG(i, 5)
parmInvoiceStatus.Value = 0
cmd.ExecuteNonQuery()
Next
Catch ex As Exception
MsgBox(ex.ToString)
Return
Finally
conn.Close()
End Try
"Cor" <no*@non.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
Hi JFB
Basicly, just bind it and than you do not have to do that for each loop to
fill it either, something like
\\\
dg.datasource=hset.tables(0)
///
And then
\\\
DirectCast(BindingContext(hset.Tables(0)),
CurrencyManager).EndCurrentEdit() ///
Before
\\\
hAdapter.update(hSet)
///
The last can nicer have for that a look to haschanges and getchanges.
I hope this helps?
Cor
Cor I forgot to tell you that this flexgrid has the same properties as
datagrid.
How do you update the dataset with you datagrid?
Tks again
JFB
"Cor" <no*@non.com> wrote in message
news:ep*************@TK2MSFTNGP12.phx.gbl... Hi JFB,
Asuming that you can want to process the items from the flexgrid I do this in psuedo because I do not know the flexgrid.
To fill the flexgrid (I hope this is posible)
\\\as far as the flexgrid pseudo the rest maybe typos but further probably correct
dim i as integer
dim y as integer
for i = 0 to hset.tables(0).rows.count-1
for y = 0 to hset.tables(0).columns.count - 1
flexgrid.row(i).item(y) = hset.tables(0).rows(i).(y)
next
next
///
If you do not use a part of the for loop with the y you also can do
\\\
flexgrid.row(i).itemx = hset.tables(0).rows(i).item("itemx")
///
How to update the dataset from the flexgrid I think that that you
should find out first yourself because that is just how you use it. But you
have to do that with every event in the flexgrid.
And keep in mind not to use the "remove" method from the dataset.
I hope this helps?
Cor
"> Tks for reply and help Cor,
> Now we are talking... I think I got the picture but not the code.
> How can insert the rows to the dataset?
>
> JFB
> 'Fill dataSet with orders table (I dont want to do it because I dont
want to
> retrieve any data)
>
> cmdSQL.CommandText = "Select * from orders"
>
> hAdapter.SelectCommand = cmdSQL
>
> hAdapter.Fill(hSet, "orders")
>
> 'Here is the problem
>
> hSet.Tables(0).Rows(myFlexgrid. ??? ).insert ????
>
> 'To update the adapter
>
> hAdapter.update(hSet)
>
>
>
>