Connect to a database in html

using vb to connect to a database in html

Page 1 of 1

3 Replies - 2064 Views - Last Post: 12 May 2010 - 11:28 AM Rate Topic: -----

#1 darkness3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 04-May 10

Connect to a database in html

Posted 11 May 2010 - 10:17 PM

I am doing my final in html, and we are using web expression 3. I am trying to connect to my database using vb, but I don't know the syntex to tell it that I want to use my input box on my web page as the string. I have never done this before in html, so I am lost. Any advice is apprecieted much.

My input box is named TxtUser on my html page



Dim ArrayData(3, 3) As String
            Dim intRow As Integer = 0
				    Dim strUser As String
				    Dim strPass As String
            Dim ArrayLog() As String = {strUser, strPass}
            Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =C:\Users\Nathaniel More\My Web Site\ubuntu\base\datalogin.accdb;Persist Security Info=False;")
            Dim StrSQL As String = "INSERT INTO DATALOGIN(LOGIN, PASSWORD) values(@loguser, @logpass)"
            Dim command As New OleDbCommand()

            For intColumn = 0 To 1
                ArrayLog(intColumn, intRow) = ArrayLog(intColumn)
            Next intColumn
            intRow += 1

            command.CommandText = StrSQL 'Tells it that command is going to be text
            command.Connection = con 'Set the conection = to con
            command.Parameters.Clear() ' Clear the all parameters

            Dim ParameterDate As New OleDbParameter 'Set up the Parmeter for the date field in the data base
            ParameterDate.ParameterName = "@loguser"
            ParameterDate.OleDbType = OleDbType.Char
            ParameterDate.Size = 100
            ParameterDate.Direction = ParameterDirection.Input
            ParameterDate.Value = ArrayLog(0)

            Dim ParameterTime As New OleDbParameter 'Set up the Parmeter for the time field in the data base
            ParameterTime.ParameterName = "@logpass"
            ParameterTime.OleDbType = OleDbType.Char
            ParameterTime.Size = 100
            ParameterTime.Direction = ParameterDirection.Input
            ParameterTime.Value = ArrayLog(1)
            'Now that the parmeters have been defined add them
            command.Parameters.Add(ParameterDate)
            command.Parameters.Add(ParameterTime)

            con.Open()
            command.ExecuteNonQuery()
            con.Close()


Is This A Good Question/Topic? 0
  • +

Replies To: Connect to a database in html

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Connect to a database in html

Posted 12 May 2010 - 09:24 AM

Can't do it. Or if you can, it's a really, really, really bad idea. Clients should never have direct DB access. That's a gaping security hole. It will be exploited.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Connect to a database in html

Posted 12 May 2010 - 11:05 AM

For starters HTML & CSS isn't the proper forum so I'll be moving this to the ASP.NET forum (since you say it's web work). Second, HTML is nothing but a markup language, it cannot program and it cannot connect to a database, period. Now HTML5 can do some stuff, but interacting with a database isn't one of them
Was This Post Helpful? 0
  • +
  • -

#4 keakTheGEEK  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 107
  • View blog
  • Posts: 344
  • Joined: 23-February 10

Re: Connect to a database in html

Posted 12 May 2010 - 11:28 AM

As @PsychoCoder and @Oler1s say, you can't do this in html. That code you have provided is VB .NET and would need to go in a .aspx page using ASP .NET. You can't put that code in an HTML form and expect it to work...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1