You are viewing limited content. For full access, please sign in.

Question

Question

How can I connect html (aspx) to mssql

asked on February 12, 2018

Hi all, I know this is not really a laserfiche's question, but maybe someone already did it and help me?

From Laserfiche Form, I saved records in my database (under mssql) ; each record refers to a Laserfiche form.

 

Using html (aspx), I want to make a list's page from my database but I don't know aspx.

 

 

This is my database

 

And this is what I want

 

I tried this code (aspx) but unsucces.

<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Data
Dim oDR as System.Data.SQLClient.SQLDataReader
Dim oCom As System.Data.SQLClient.SqlCommand
Dim oConn as System.Data.SQLClient.SQLConnection

Try
'Enter the database server address, initial catalog(database name),
'uid(username) and pwd(password) in the line below
oConn = New System.Data.SQLClient.SQLConnection ("server=USER1\LASERFICHE; initial catalog=Mydatabase;uid=USER1\Olivier;pwd=Mypassword;")
oConn.Open()
oCom = New System.Data.SQLClient.SqlCommand()
oCom.Connection = oConn
'Enter your SQL query within the quotes in the line below
oCom.CommandText = "SELECT * FROM dbo.Poste_a_pourvoir"
oDR = oCom.ExecuteReader()
While oDR.Read
'Enter a column name within the quotes below for each item
Response.Write(oDR.Item("specialite_recherchee") & ", " & oDR.Item("poste_a_pourvoir"))
Response.Write("<BR/>")
End While
Catch
Response.Write("Error:" & err.Description)
Finally
oDR = Nothing
oCom = Nothing
oConn.Close()
oConn = Nothing
End Try
End Sub
</script>

<html>
<title>Queries from the MS-SQL database with ASP.NET</title>
<body bgcolor="FFFFFF">
<h2>Query from table <b>products</b> with ASP.NET</h2>
<%Page_Data()%>
</body>
</html>

This is the error

The login is correct! I use it with Mssql Management Studio with no problem.

 

Thank you in advance.

Regards

 

0 0

Answer

SELECTED ANSWER
replied on February 12, 2018

I'm not sure you can do Windows authentication by putting your domain credentials in the connection string.  You may need to create a separate account that can authenticate with a password.

1 0
replied on February 12, 2018

Brian is right, even from SQL Studio you can't just enter domain credentials into the user/pass inputs when working with Microsoft SQL. Create a SQL user.

Also, database connections work best server side, you can use PHP to execute server side code instead of running the code in the client browser. This also prevents any of the authentication information from being available to the user.

0 0
replied on February 13, 2018

The script block is "runat=server", so it is executed while rendering the page server-side.  Only the data within the Response.Write calls is sent back to the browser.

0 0
replied on February 14, 2018

Ah, good deal. Didn't know VB had that option.

0 0
replied on February 14, 2018

Thank you Brian, it's working with a new login.

Regards

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.