-1
How do I connect an sql database to an html site using Asp?
Observing: I already have the entire bank developed and the full page too, I just need to know how to bridge the gap between the two
-1
How do I connect an sql database to an html site using Asp?
Observing: I already have the entire bank developed and the full page too, I just need to know how to bridge the gap between the two
2
There are several ways to solve your problem. I would use the Entity framework to map my database objects into classes (database-first) and insert my conectionstring into the config. After this, in your controller (if it’s MVC), refer to the database connection and perform the required query by storing the results in a list<>. Send the controller list to view via viewmodel..
Ex. controller: Private Productoscontext Bancodedados = new Productoscontext ();
List products = new list Products = Bancodedados.Produtos.Tolist();
*need to create a class Products() with its properties, example: Productoid, Name, Description, Preco {get;set;} etc..
I recommend you read these two articles.
1
Gui Sartori, it is good to put some details that make the difference type:
If Asp classico follows
'<%
Dim conexao, stringConexao, host, usuario, senha, banco
host ="SERVIDOR"
usuario="BASE"
senha ="SENHA"
banco ="BANCO"
Monta a string de conexão utilizando os dados informados anteriormente
stringConexao ="Provider=SQLNCLI10;
SERVER="&host&";DATABASE="&banco&";UID="&usuario&";PWD="&senha&";"
##Instancia o objeto de conexão com o banco
SET conexao = Server.CreateObject("ADODB.Connection")
On Error Resume Next
##Abre a conexão junto ao banco
conexao.Open stringConexao
##Tratamento de erro. Caso ocorra problemas na conexão, exibe esta informação e apresenta detalhes.
If Err.Number <> 0 Then
response.write "<b><font color='red'>Conexão com o banco'"&banco&"'Microsoft SQL Server falhou !</font></b>"
response.write "<BR><BR>"
response.write "<b>Erro.Description:</b> " & Err.Description & "<br>"
response.write "<b>Erro.Number:</b> " & Err.Number & "<br>"
response.write "<b>Erro.Source:</b> " & Err.Source & "<br>"
Else
##Caso a conexão seja bem sucedida, mostra mensagem de confirmação.
response.write "<b><font color='blue'> Conexão com o banco '" & banco & "' Microsoft SQL Server estabelecida com sucesso !</font>"
End If
##Fecha a conexão com o banco
conexao.close
##Remove as referência do objeto da memória
SET conexao = Nothing
%>
I don’t know I saw this code on the wiki access here
Browser other questions tagged html sql-server asp
You are not signed in. Login or sign up in order to post.
I use JSON and recommend it. 1) Create a connection page with the database with classic Asp[ Conn.Asp ]; 2) Create an Asp file containing code to generate JSON[ arquivo_json.Asp ]; 3) Put Conn.Asp as include on the file page_json.Asp; 4) Use JQUERY to retrieve the information from the file json.Asp and put it where you want in the HTML page. On my site I do a step by step see [ http://programano.marsites.com.br/? p=67 ]
– Wilson Rosa Gomes
hello, access this site I think will help you http://programano.marsites.com.br/? p=67
– Wilson Rosa Gomes