Vb6 to C#-especially the part where they update the column in the datatable

  • 12 years ago

    Hi! guys.. 

    Function FreeItemsRefNumber(addno As Integer)

    Dim rs As New ADODB.Recordset

    rs.CursorType = adOpenDynamic

    rs.LockType = adLockOptimistic

    rs.Open
    "SELECT * FROM FreeItemsRefNumber", clslib.cnn1

    If rs.EOF = True Or rs.BOF = True Then

    rs.AddNew

    rs(
    "LastSerialNumber") = -1

    Else

    //i know how to add a new row, but how do i update

    rs(
    "LastSerialNumber") = rs("LastSerialNumber") - addno

    End If

    rs.Update

    FreeItemsRefNumber = rs(
    "LastSerialNumber")

    rs.Close

    Set rs = Nothing

    End Function

     ````````````````````````````````````````````````````````````````````

    using (SqlDataAdapter da = new SqlDataAdapter(sql, sqlConn))

    {

     

    da.Fill(dt);

    if(dt.Rows.Count<0)

    {

    DataRow dr=dt.NewRow();dr["LastSerialNumber"]=-1;

    dt.Rows.Add(dr);

    } else

    {

     

    }

     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The question of whether computers can think is just like the question of whether submarines can swim.” - Edsger W. Dijkstra