Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:51:43+00:00 2026-06-15T04:51:43+00:00

I am trying to insert some data from my web app into a database

  • 0

I am trying to insert some data from my web app into a database table. Whenever I run the code it jumps to the exception straightforward. Even if I set breakpoints, the debugging doesn’t stop in order for me to check the parameters. I even checked if the table would accept the datatype inserted from my web app by inserting the same data manually into the table and its working.

Here is my code

 Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim IP As String = TextBox3.Text
        Dim Country_Code As String = TextBox4.Text
        Dim Country As String = TextBox5.Text

        Dim conn As New SqlConnection("Data Source=***.***.***.***;Initial Catalog=IP_Loc;User ID=********;Password=************;Integrated Security=True")
        Dim cmd As New SqlCommand

        Try
            conn.Open()
            cmd = New SqlCommand("INSERT INTO IP_Info(IP, Country_Code, Country) VALUES (@IP, @Country_Code, @Country)", conn)
            cmd.Parameters.AddWithValue("@IP", IP)
            cmd.Parameters.AddWithValue("@Country_Code", Country_Code)
            cmd.Parameters.AddWithValue("@Country", Country)
            cmd.ExecuteNonQuery()
            conn.Dispose()
            conn.Close()

        Catch ex As Exception
            MsgBox("Database Connection Error")
        End Try

I have covered the User ID and Password as it is a local server. Any suggestions on how to tackle the issue?

Here is the Error it is at conn.open()

System.Data.SqlClient.SqlException: Login failed for user 'Server'. 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.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:51:44+00:00Added an answer on June 15, 2026 at 4:51 am

    you have declared sqlcommand two times. corrected program

     Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    
                Dim IP As String = TextBox3.Text
                Dim Country_Code As String = TextBox4.Text
                Dim Country As String = TextBox5.Text             
                    Try
            Dim conn As New SqlConnection("Data Source=***.***.***.***;Initial   Catalog=IP_Loc;User ID=********;Password=************;Integrated Security=True")
                    conn.Open()
                Dim cmd As New SqlCommand("INSERT INTO IP_Info(IP, Country_Code, Country) VALUES (@IP, @Country_Code, @Country)", conn)
                    cmd.Parameters.AddWithValue("@IP", IP)
                    cmd.Parameters.AddWithValue("@Country_Code", Country_Code)
                    cmd.Parameters.AddWithValue("@Country", Country)
                    cmd.ExecuteNonQuery()
                    conn.Dispose()
                    conn.Close()
    
                Catch ex As Exception
                    MsgBox("Database Connection Error")
                End Try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert some data from a proprietary JSON database into MongoDB for
I'm trying to insert some data into a table from a csv document which
I'm trying to insert some data from a XML document into a variable table.
I am trying to insert some data from excel file into a table. I
I am trying to insert some data from one table into another but I
I am trying to insert some data into a pysqlite database but even tho
I am trying to insert some text data into a table in SQL Server
I'm trying to insert some binary data into database using 'mysql' gem in ruby.
I am trying to read some data from html forms and insert it into
I am trying to insert some data into one table and after that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.