Results 1 to 3 of 3

Thread: Insert row into SQL table using webform

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    683

    Insert row into SQL table using webform

    I know how to do inserts with a windows app but this is my first web app and I have not had alot of luck. I have a form with lots of textboxs and a submit button. For trial purposes, I am only going to submit 3 of the textboxes. Here is the code,
    VB Code:
    1. Imports System.data.sqlclient
    2. Imports System.Data
    3.  
    4. Public Class Identification
    5.     Inherits System.Web.UI.Page
    6.  Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    7.        
    8.  
    9.         Dim cnCF98 As New SqlConnection
    10.  
    11.         cnCF98.ConnectionString = "integrated security=true;initial catalog=tempdb"
    12.         cnCF98.Open()
    13.  
    14.         Dim cmdtext As String = "Insert ID ( SN, Surname, Given) VALUES  (" & txtSN.Text & ", " & txtSurname.Text & ", " & txtGiven.Text & " )"
    15.         Dim cm As New SqlCommand(cmdtext, cnCF98)
    16.         cm.ExecuteNonQuery()
    17.         cnCF98.Close()
    18. End Sub
    19. End Class
    I get this error -
    Server Error in '/WebApplication1' Application.
    --------------------------------------------------------------------------------

    SQL Server does not exist or access denied.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

    Source Error:


    Line 110:
    Line 111: cnCF98.ConnectionString = "integrated security=true;initial catalog=tempdb"
    Line 112: cnCF98.Open()
    Line 113:

    Line 112 is in red. I am sure this is probably a security setup problem but have had no luck. I have added the
    <identity impersonate="true" /> to the webconfig file but no luck with that either. Any help would be a good thing.

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    your connection string does not point to a server

    Try this
    VB Code:
    1. cnCF98.ConnectionString = "integrated security=SSPI;data source=computername;initial catalog=tempdb"
    Last edited by CyberHawke; Jun 29th, 2004 at 10:25 AM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    683
    WOW, look at a problem hard and you cannot see the trees for the forest. THanks, That was just plain dumb on my part.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width