Are there another choice for ExecuteNonQuery?  
Author Message
ekke





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

Are there anohter choice in Visual Basic 2000 instead for executeNonQuery. For the moment I use this command in while-loop.

The problem is that it seems the executeNonQuery only run one time in the while-loop, even it suppose run many times if the the while-loop runs more then on time.



.NET Development24  
 
 
Prasant Swain





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

do you post your code then it will better you to suggest you something.

 
 
ekke





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

Here are some code

While Sum <> 0

connDatagrid = New MySqlConnection()

connDatagrid.ConnectionString = ConnectionString

connDatagrid.Open()

Try

For IdLoop = 1 To DepartLoop

MessageBox.Show(IdLoop)

myCommand.Connection = connDatagrid

myCommand.CommandText = "update vnstelefon set idnr = idnr + 1" + " where idnr = " + TextBoxIDnr.Text.ToString + " and orginal = '" + ComboBoxDepart.SelectedItem + "'"

myCommand.ExecuteNonQuery()

IdLoop = IdLoop + 1

Next IdLoop

Catch myerror As MySqlException

MessageBox.Show(TextBoxName.Text & " kunde inte laggas till " & myerror.Message)

End Try

'MessageBox.Show(myCommand.ExecuteNonQuery)

MessageBox.Show(myCommand.CommandText)

DepartLoop = DepartLoop + 1

TextBoxIDnr.Text = DepartLoop

Sum = Sum - 1

connDatagrid.Close()

End While


 
 
Prasant Swain





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

you can try this way

For IdLoop = 1 To DepartLoop

MessageBox.Show(IdLoop)

myCommand = New SqlCommand()

myCommand.Connection = connDatagrid

myCommand.CommandText = "update vnstelefon set idnr = idnr + 1" + " where idnr = " + TextBoxIDnr.Text.ToString + " and orginal = '" + ComboBoxDepart.SelectedItem + "'"

myCommand.ExecuteNonQuery()

myCommand.Dispose()

Next IdLoop



 
 
ekke





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

It didn't help. I got the same result. Any other suggestions
 
 
Prasant Swain





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

are you doing exactly what you are written. then since the value of idno changes in the first execution then there is no chances to execute the command again. as after the first execution the idno value will not match with the textbox value. you can debug and test it.

 

can you try like this.

 

connDatagrid = New SqlConnection()

connDatagrid.ConnectionString = ConnectionString

connDatagrid.Open()

While Sum <> 0

Try

For IdLoop = 1 To DepartLoop

MessageBox.Show(IdLoop)

myCommand = new SQLCommand()

myCommand.Connection = connDatagrid

myCommand.CommandText = "update vnstelefon set idnr = idnr + 1" + " where idnr = " + TextBoxIDnr.Text.ToString + " and orginal = '" + ComboBoxDepart.SelectedItem + "'"

myCommand.ExecuteNonQuery()

myCommand.Dispose()

Next IdLoop

Catch myerror As MySqlException

MessageBox.Show(TextBoxName.Text & " kunde inte laggas till " & myerror.Message)

End Try

'MessageBox.Show(myCommand.ExecuteNonQuery)

MessageBox.Show(myCommand.CommandText)

DepartLoop = DepartLoop + 1

TextBoxIDnr.Text = DepartLoop

Sum = Sum - 1

End While

connDatagrid.Close()



 
 
ekke





PostPosted: .NET Framework Data Access and Storage, Are there another choice for ExecuteNonQuery? Top

Still I get the same result. Are there any other solutions for this problem