Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

VS 2010 Error with execute multiple SQL statements using a SqlCommand !

$
0
0
Hi all

I am tray to execute multiple SQL statements using a SqlCommand, but it gave me error :
there was an error parsing the query. [token line number = 1, token line offset = 150, token in error = insert]
What does it mean? and how can i solve it?
my code :

Code:

Dim con As New SqlCeConnection
        Dim cmd As New SqlCeCommand
        Try
            con.ConnectionString = "Data Source=|DataDirectory|\db1.sdf"
            con.Open()
            cmd.Connection = con
            cmd.CommandText = "INSERT INTO ShortGoalsP (NonKnownSkill,IDShortGoal,ShortGoalP,IDStudent) " +
                              "SELECT Skill,IDShortGoal,ShortGoal, @parameter " +
                              "FROM ShortGoals " + "WHERE YorN=1;" +
                              "INSERT INTO DailyGoalsP (IDShortGoalP,DailyGoalP,IDStudent) " +
                              "SELECT IDShortGoal,DailyGoal,@parameter " + "FROM DailyGoals " +
                              "WHERE YorN=1;"
            cmd.Parameters.Add("@parameter", SqlDbType.Int).Value = CInt(TextBox1.Text)

            cmd.ExecuteNonQuery()



         
            cmd.CommandText = "UPDATE ShortGoals SET YorN=NULL; " + "UPDATE DailyGoals SET YorN=NULL; "
            cmd.ExecuteNonQuery()
            MsgBox("successful")

        Catch ex As Exception
            MessageBox.Show("not successful"& ex.Message)
        Finally
            con.Close()
        End Try

the curse code from here : http://www.java2s.com/Tutorial/CShar...mandobject.htm

Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>