Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Must declare the scalar variable????

Author  Topic 

FHM786
Starting Member

1 Post

Posted - 2009-01-06 : 02:53:14
Im getting the error Must declare the scalar variable "@AbsSurveyId"


Please help





Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim conNorthwind As SqlConnection

Dim strInsert As String


Dim cmdInsert As SqlCommand

conNorthwind = New SqlConnection("Server=XXXXXXX;database=XXXXXXXXXX;Integrated Security=True")

strInsert = "INSERT INTO AbsSurvey(AbsSurveyId, EmpName, EmpRegion, EmpDept, DeptWorkforce, AvgDaysLost, CostMonitored, DirectCost, Trend, Distinguished, Illness, Family, Personal, Stress, Entitlement, OtherReasons, OtherDesc, ChangeUser, ChangeDate) VALUES (@AbsSurveyId, @EmpName, @EmpRegion, @EmpDept, @DeptWorkforce, @AvgDaysLost, @CostMonitored, @DirectCost, @Trend, @Distinguished, @Illness, @Family, @Personal, @Stress, @Entitlement, @OtherReasons, @OtherDesc, @ChangeUser, @ChangeDate)"

cmdInsert = New SqlCommand(strInsert, conNorthwind)

conNorthwind.Open()

cmdInsert.ExecuteNonQuery()

conNorthwind.Close()



End Sub

Fahèém Suleman

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-01-06 : 05:44:14
You are not assigning any values to the sql variables. @AbsSurveyId and all the other insert variables need to have values before you can do the insert.

- Lumbago
Go to Top of Page
   

- Advertisement -