Click here to Skip to main content
16,004,587 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys, ive got a small problem here... My program runs on localhost but when i click add button some message on the browser appear

here is my code:
<script language="VB" runat="server">
    Protected Sub add_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim DBConn As New SqlClient.SqlConnection("Data Source=ML0003135586;Integrated Security=SSPI;" & "Initial Catalog=TestSQL")
        Dim DBCmd As New SqlClient.SqlCommand
        Dim DBAdap As New SqlClient.SqlDataAdapter
        Dim DS As New DataSet
        DBConn.Open()
        Try
            DBCmd = New SqlClient.SqlCommand("INSERT INTO [GEE5](costcenter, title, code, duration, attendees, batches) VALUES (@CostCenter, @Course_Title, @Course_Code, @Course_Duration, @Target_Attendees, @Target_Batches)", DBConn)
            DBCmd.Parameters.Add("@CostCenter", SqlDbType.NVarChar).Value = CCenter.Text
            DBCmd.Parameters.Add("@Course_Title", SqlDbType.NChar).Value = txtTitle.Text
            DBCmd.Parameters.Add("@Course_Code", SqlDbType.NVarChar).Value = txtCode.Text
            DBCmd.Parameters.Add("@Course_Duration", SqlDbType.NVarChar).Value = txtDuration.Text
            DBCmd.Parameters.Add("@Target_Attendees", SqlDbType.NVarChar).Value = txtAttendees.Text
            DBCmd.Parameters.Add("@Target_Batches", SqlDbType.NVarChar).Value = txtBatches.Text
            DBCmd.ExecuteNonQuery()
            Response.Write("Your Record is Updated ")
            DBAdap = New SqlClient.SqlDataAdapter("SELECT * FROM [GEE5]", DBConn)
        Catch exp As Exception
            Response.Write(exp)
        End Try
        DBCmd.Dispose()
        DBAdap.Dispose()
        DBConn.Close()
        DBConn = Nothing
    End Sub


Here is the error message
System.Data.SqlClient.SqlException: Invalid object name 'GEE5'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.dataadd_aspx.add_Click(Object sender, EventArgs e) in C:\Documents and Settings\oca14625\Desktop\TRYING2\dataadd.aspx:line 20




Cost Center:                      12950 12939

Course Title:

Course Code:

Course Duration:

Target Attendees:

Target Batches:

Plss help me im new here... thanks in advance
Posted

1 solution

Check your connection string,

If it is fine then check the table name GEE5 in your database the name in query should be same as name in database.
 
Share this answer
 
v2
Comments
janwel 2-May-11 0:38am    
found it.. my problem is the table name is GEE51 not GEE5 thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900