Autonumber retreival

shukla

New member
Joined
Dec 9, 2008
Messages
4
Programming Experience
3-5
VB.NET:
Dim ConnectionString As String = "server=dataserver;initial catalog=nash;persist security info=true;user id=sa;password=nimda"
        Dim conn As SqlConnection = New SqlConnection(ConnectionString)

        conn.Open()

        Dim adapter As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM customer ORDER BY ID", conn)

        Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)

        ' Create a dataset object
        Dim ds As DataSet = New DataSet("customer")
        adapter.Fill(ds, "customer")

        ' Create a data table object and add a new row
        Dim T As DataTable = ds.Tables("customer")
        Dim row As DataRow = T.NewRow()
        row("cName") = "Aparna shukla"
        row("address") = "moon"
        'row["ID"] = "10";
        T.Rows.Add(row)
        MsgBox("Record added")
        ' Update data adapter
        adapter.Update(ds, "customer")
Now here id as autonumber field for table.
After adding data to table i want added row's id value.
How to get it ??
 
If you upgrade to VS2005 or later, you can tick a box in the tableadapter wizard titled "Refresh the dataset" - VS will automatically make a query that retrieves the identity value
 

Latest posts

Back
Top