Click here to Skip to main content
16,004,927 members
Home / Discussions / Database
   

Database

 
GeneralRe: read from ps2 port Pin
Frank Kerrigan15-Nov-06 3:19
Frank Kerrigan15-Nov-06 3:19 
QuestionAbout Swapping in Sql Pin
prameelapydi13-Nov-06 17:45
prameelapydi13-Nov-06 17:45 
AnswerRe: About Swapping in Sql Pin
Colin Angus Mackay13-Nov-06 22:54
Colin Angus Mackay13-Nov-06 22:54 
GeneralRe: About Swapping in Sql Pin
Frank Kerrigan13-Nov-06 23:40
Frank Kerrigan13-Nov-06 23:40 
GeneralRe: About Swapping in Sql Pin
prameelapydi15-Nov-06 17:55
prameelapydi15-Nov-06 17:55 
Questionhow can i make data visualisation? [modified] Pin
MAYKY13-Nov-06 8:03
MAYKY13-Nov-06 8:03 
AnswerRe: how can i make data visualisation? Pin
Frank Kerrigan13-Nov-06 23:51
Frank Kerrigan13-Nov-06 23:51 
Questionupdating a database using dataAdapter update Pin
steve_rm13-Nov-06 6:43
steve_rm13-Nov-06 6:43 
Hello,

I want to update a database. the code i have below gets all the values from a table called roles, and populates a dataset.

I then have a datatable that i want to add some new rows too. I then add this rows to the data table and add the data table to the dataset.

I then want to update the database by calling the dataAdapter update command. The code below as a problem with the update.

I have been told that the insertcommand would be better, but not sure, as i have never used that below. Can anyone give any advice on this.

Many thanks in advance,

Steve


using VB 2005 and SQL Server 2005
<br />
 Dim i As Integer<br />
        Dim dt As New DataTable()<br />
        Dim dr As DataRow<br />
        Dim userID As Integer<br />
        Dim ds As New DataSet()<br />
        Dim da As New SqlDataAdapter()<br />
        Dim cmd As New SqlCommand()<br />
        Dim cnn As New SqlConnection<br />
        Dim cb As New SqlCommandBuilder()<br />
<br />
        dt.Columns.Add("UserID")<br />
        dt.Columns.Add("GroupID")<br />
        Try<br />
            cnn.ConnectionString = "server=.; database=serviceMaster; integrated security = true"<br />
            cnn.Open()<br />
            cmd.Connection = cnn<br />
            cb.DataAdapter = da<br />
            cmd.CommandType = CommandType.Text<br />
            cmd.CommandText = "SELECT * FROM Roles"<br />
<br />
            da.SelectCommand = cmd<br />
            da.Fill(ds)<br />
            dt = ds.Tables(0)<br />
<br />
        Catch ex As Exception<br />
<br />
        End Try<br />
<br />
        userID = 24<br />
        Dim chklstIndexes As CheckedListBox.CheckedIndexCollection = Me.chkLstSecurityRoles.CheckedIndices<br />
<br />
        For i = 0 To Me.chkLstSecurityRoles.CheckedItems.Count - 1<br />
            dr = dt.NewRow()<br />
            dr("userID") = userID<br />
            dr("GroupID") = chklstIndexes.Item(i)<br />
            dt.Rows.Add(dr)<br />
        Next<br />
<br />
        'Add to the dataset and use the dataAdapter to update the database<br />
        Try<br />
            ds.Tables.Add(dt)<br />
            cb.GetUpdateCommand()<br />
            da.Update(ds)<br />
        Catch ex As Exception<br />
<br />
        End Try<br />

AnswerRe: updating a database using dataAdapter update Pin
Frank Kerrigan13-Nov-06 23:56
Frank Kerrigan13-Nov-06 23:56 
QuestionHow to Add(sum) from two Different tables Pin
Iridania13-Nov-06 4:40
Iridania13-Nov-06 4:40 
AnswerRe: How to Add(sum) from two Different tables Pin
Parwej Ahamad13-Nov-06 5:59
professionalParwej Ahamad13-Nov-06 5:59 
QuestionStored Procedure Issue Pin
Deepasubramanian13-Nov-06 4:12
Deepasubramanian13-Nov-06 4:12 
AnswerRe: Stored Procedure Issue Pin
coolestCoder13-Nov-06 21:20
coolestCoder13-Nov-06 21:20 
AnswerRe: Stored Procedure Issue Pin
Deepasubramanian16-Nov-06 19:17
Deepasubramanian16-Nov-06 19:17 
Questionparameter in footer - sql reports Pin
playout12-Nov-06 20:51
playout12-Nov-06 20:51 
AnswerRe: parameter in footer - sql reports Pin
Frank Kerrigan13-Nov-06 23:44
Frank Kerrigan13-Nov-06 23:44 
QuestionUPDATE & INSERT speed improvement question Pin
Lior S11-Nov-06 23:11
Lior S11-Nov-06 23:11 
AnswerRe: UPDATE & INSERT speed improvement question Pin
Software_Guy_12311-Nov-06 23:26
Software_Guy_12311-Nov-06 23:26 
AnswerRe: UPDATE & INSERT speed improvement question Pin
Colin Angus Mackay12-Nov-06 8:37
Colin Angus Mackay12-Nov-06 8:37 
QuestionRe: UPDATE & INSERT speed improvement question Pin
Lior S12-Nov-06 22:45
Lior S12-Nov-06 22:45 
AnswerRe: UPDATE & INSERT speed improvement question Pin
Colin Angus Mackay13-Nov-06 1:00
Colin Angus Mackay13-Nov-06 1:00 
QuestionCreating Database for a holding an its subsidiaries Pin
Maira K11-Nov-06 22:33
Maira K11-Nov-06 22:33 
AnswerRe: Creating Database for a holding an its subsidiaries Pin
Frank Kerrigan13-Nov-06 23:59
Frank Kerrigan13-Nov-06 23:59 
GeneralRe: Creating Database for a holding an its subsidiaries Pin
Maira K14-Nov-06 0:48
Maira K14-Nov-06 0:48 
GeneralExpress Connection Problems Pin
Ed.Poore10-Nov-06 13:49
Ed.Poore10-Nov-06 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.