Hello programmers, got a small problem here as you see i want to add a records on the database(same college, same code but different in centers).So when I click submit button 2 records are saved in my database
EX.
i put text on textboxes Hidden variables of centers
college = wew 123
code = wew 456
centers = (based on hidden variables)
SUBMIT
And when I look on the database
College Code Center
wew wew 123
wew wew 456
thats what i want, but got a problem. When I hit submit button an error occurs
Invalid object name 'tblTraningPlan'.
pointing at command.executenonquery
Plss help me.. Did I forgot something?
Thanks and more power programmers
MY CODES:
Imports System.Math
Imports System.Web
Imports System.Data.SqlClient
Imports System.Data
Partial Class Gee51
Inherits System.Web.UI.Page
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
databind15029()
databind12934()
End Sub
Public Sub databind15029()
Dim strSQL As String
Dim connection As SqlConnection = New SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "INSERT INTO tblTraningPlan(CostCenter, College, Category, CourseCode, CourseTitle, Duration) VALUES (@CostCenter, @College, @Category, @CourseCode, @CourseTitle, @Duration)"
connection.Open()
Dim command As New SqlCommand(strSQL, connection)
command.Parameters.Add("@CostCenter", SqlDbType.NVarChar).Value = lbl15029.Text
command.Parameters.Add("@College", SqlDbType.NVarChar).Value = txtCollege.Text
command.Parameters.Add("@Category", SqlDbType.NVarChar).Value = lblGEE.Text
command.Parameters.Add("@CourseCode", SqlDbType.NVarChar).Value = txtCCode.Text
command.Parameters.Add("@CourseTitle", SqlDbType.NVarChar).Value = txtCT.Text
command.Parameters.Add("@Duration", SqlDbType.NVarChar).Value = txtDuration.Text
command.ExecuteNonQuery()
connection.Close()
End Sub
Public Sub databind12934()
Dim strSQL As String
Dim connection As SqlConnection = New SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "INSERT INTO tblTraningPlan(CostCenter, College, Category, CourseCode, CourseTitle, Duration) VALUES (@CostCenter, @College, @Category, @CourseCode, @CourseTitle, @Duration)"
connection.Open()
Dim command As New SqlCommand(strSQL, connection)
command.Parameters.Add("@CostCenter", SqlDbType.NVarChar).Value = lbl12934.Text
command.Parameters.Add("@College", SqlDbType.NVarChar).Value = txtCollege.Text
command.Parameters.Add("@Category", SqlDbType.NVarChar).Value = lblGEE.Text
command.Parameters.Add("@CourseCode", SqlDbType.NVarChar).Value = txtCCode.Text
command.Parameters.Add("@CourseTitle", SqlDbType.NVarChar).Value = txtCT.Text
command.Parameters.Add("@Duration", SqlDbType.NVarChar).Value = txtDuration.Text
command.ExecuteNonQuery()
connection.Close()
End Sub
End Class