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 7775891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:44:21+00:00 2026-06-01T17:44:21+00:00

Can somebody tell me how to authenticate users with the SQL Server database table

  • 0

Can somebody tell me how to authenticate users with the SQL Server database table using VB as a web service. I managed to connect to the SQL server via this VB code;

Public Sub ConnectToSQL()
        Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Try
            con.ConnectionString = "Data Source=(local);Initial Catalog=TestDatabase;Persist Security Info=True;User ID=sa;Password=421"
            con.Open()
        Catch ex As Exception
            MessageBox.Show("Error while connecting to SQL Server." & ex.Message)
        Finally
            con.Close() 'Whether there is error or not. Close the connection.
        End Try
    End Sub

Any one ?Thank you in advance.

  • 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-01T17:44:23+00:00Added an answer on June 1, 2026 at 5:44 pm

    I would recommend that you first go through basic tutorials on SQL server as well as ADO.Net and then post questions. This will help in making your concepts clear as well as any help can be provided in more focused, problem areas. BTW, no hard feelings, just want you to be comfortable on programming. 🙂

    Step 1 :

    Create relevant database tables. These may include a users table and other tables such as roles, etc…

    EDIT : You can use SQL scripts to create tables in DB. Please find a sample below.

    -- Sample Table Creation and Index Creation script for MCIS-4423
    -- This script is designed to be "re-runnable", but you need to be careful, 
    -- Since this will DROP the table, which would be bad if it was an existing table with data
    
    -- Make sure you are in the correct database
    USE [AdventureWorks]
    GO
    
    -- Drop Check Constraint
    IF  EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Team_TeamID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Team]'))
    ALTER TABLE [dbo].[Team] DROP CONSTRAINT [CK_Team_TeamID]
    GO
    
    -- Drop Table
    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Team]') AND type in (N'U'))
    DROP TABLE [dbo].[Team]
    GO
    
    -- Create Table
    CREATE TABLE [dbo].[Team](
        [TeamID] [char](3) NOT NULL,
        [TeamName] [varchar](20) NOT NULL,
        [City] [varchar](50) NOT NULL,
        [StateCode] [char](2) NULL,
        [PostalCode] [char](5) NULL,
    CONSTRAINT [PK_Team] PRIMARY KEY CLUSTERED  
    (
        [TeamID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    
    -- Add Check Constraint
    ALTER TABLE [dbo].[Team]  WITH CHECK ADD  CONSTRAINT [CK_Team_TeamID] CHECK  (([TeamID] like '[A-Z][A-Z][A-Z]'))
    GO
    ALTER TABLE [dbo].[Team] CHECK CONSTRAINT [CK_Team_TeamID]
    GO
    
    -- Drop index if it exists
    IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Team]') AND name = N'IX_Team_TeamName')
    DROP INDEX [IX_Team_TeamName] ON [dbo].[Team] WITH ( ONLINE = OFF )
    GO
    
    -- Add non-clustered index on StateCode column
    -- Use ONLINE = ON if you have Developer or Enterprise Edition
    -- Use MAXDOP = 2 (set to roughly 25% of the number of CPU cores to keep index creation from affecting performance)
    CREATE NONCLUSTERED INDEX [IX_Team_TeamName] ON [dbo].[Team] 
    (
        [StateCode] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, MAXDOP = 2, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    GO
    

    Please note that this sample is copied from http://sqlserverperformance.wordpress.com/2007/09/27/sample-table-and-index-creation-script-for-sql-server-2005/ and all credit related to its content goes to the author who wrote it.

    Step 2 :

    Write SQL query to find a user based on his username and password. You may go for password encryption, but that is out of scope for current question.

    EDIT : Sample query can be as follows :

    SELECT username FROM users
    WHERE username=@username and password=@password
    

    You can read through SqlCommand documentation here to understand how to add parameters to a query.

    Step 3 :

    Add WebMethods so that you can create users records in database. Use SqlCommand to fire INSERT queries on your database tables.

    EDIT : Read here for a sample on how to write web services in VB.Net. And yes, you already know now, how to use SqlCommand to fire SQL queries, do the same for INSERT queries too.

    Step 4 :

    Create a WebMethod, that validates a user. For this, use SqlCommand object to fire your query written in Step 2. If you get a row as a result, the user is valid.

    EDIT : Refer instructions to above steps and you should be able to create this on your own.

    Hope I am clear enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody tell me why mysql is not using the correct index in the
I am converting a string to datetime using DateTime.TryParse in C#. Can somebody tell
Can somebody tell me how to focus on particular part of a web page
can somebody tell me how can I check whether a table exists in microsoft
can somebody tell me how to populate jquery fullcalendar events using ajax. There is
Can somebody tell me how to focus the html textfield using JavaScript? I am
I am having problems using a LoginView for what I need. Can somebody tell
I need to rebuild the following object in an Oracle database...can somebody tell me
Can somebody tell me how I can find out how many threads are in
can somebody tell me why my code is not working? class Connection { public

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.