Line break VB.NET

D

dancer

Using VB.Net and ASP.Net 1.1

Here is a VERY simple MS Access database request.

How can I get a line break between the name, address, & city fields when
they are written?

& vbCrLf _ returns an error of " End of statement expected."


<%@ Page Language="VB" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)


Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" & _

"Data Source=C:\Inetpub\wwwroot\Experiment.mdb" )

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Experiment")

Dim SQLString AS String

SQLString = "SELECT * FROM Table1"

DBCommand = New OleDBCommand(SQLString, DBConnection)

Dim DBReader AS OledbDatareader

DBReader = DBCommand.ExecuteReader()


While DBReader.Read()

Response.Write("Name is " & DBReader("Name"))
Response.Write(DBReader("Address1"))

Response.Write(DBReader("city"))

End While

DBReader.Close()

DBConnection.Close()

End Sub

</script>

</head>

<body>

<form id="form1" runat="server">

</form>

</body>

</html>
 
J

Juan T. Llibre

You don't need the ampersand. Just use :

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" _
"Data Source=C:\Inetpub\wwwroot\Experiment.mdb" )





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
A

Alexey Smirnov

You don't need the ampersand. Just use :

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" _
"Data Source=C:\Inetpub\wwwroot\Experiment.mdb" )

Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en español :http://asp.net.do/foros/
======================================

You need the ampersand.

Regarding line break

Response.Write("Name is " & DBReader("Name") & "<br>")
Response.Write(DBReader("Address1") & "<br>")
Response.Write(DBReader("city") & "<br>")
 
J

Juan T. Llibre

I must be getting lysdexic in my advanced age.

Sorry for the crossed wire.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
You don't need the ampersand. Just use :

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" _
"Data Source=C:\Inetpub\wwwroot\Experiment.mdb" )

Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en español :http://asp.net.do/foros/
======================================

You need the ampersand.

Regarding line break

Response.Write("Name is " & DBReader("Name") & "<br>")
Response.Write(DBReader("Address1") & "<br>")
Response.Write(DBReader("city") & "<br>")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top