PDA

View Full Version : Error VBscript Expected end of statement -.-


vik999
10-06-2009, 09:44 AM
Hello i was wondering if someone could help me solve this becouse going insane with this stupid error. im getting this:

Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/oooo/home_page.asp, line 52, column 10
Dim fdCon As String = "Driver={MySQL ODBC 3.51 Driver};Server=serverIP;Database=DBname;user id=user;password=password;OPTION=3"
---------^

Code goes like this:
<%
Dim fdCon As String = "Driver={MySQL ODBC 3.51 Driver};Server=serverIP;Database=DBname;user id=user;password=password;OPTION=3"
Dim oConnection As System.Data.Odbc.OdbcConnection = New System.Data.Odbc.OdbcConnection(fdCon)
Dim fdCom As New System.Data.Odbc.OdbcCommand("SELECT * FROM news", oConnection)

oConnection.Open()

Dim objAdapter1 As New System.Data.Odbc.OdbcDataAdapter()
objAdapter1.SelectCommand = fdCom

Dim objDataset1 As New DataSet()
objAdapter1.Fill(objDataset1, "news")
GridView1.DataSource = objDataset1.Tables(0).DefaultView()
GridView1.DataBind()

oConnection.Close()
%>

<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

now this does work on local server IIS when its in .aspx but fails if i try to put it in .asp .
any help of how i can make it work or what do i need to change in .asp file would be greatly appreciate :p
thnx in advance.

shakir
10-06-2009, 02:31 PM
Dim fdCon As String is allowed in visual basic but not in vb script

So do the following in the declaration

Dim fdCon
fdCon = "Driver={MySQL ODBC 3.51 Driver};Server=serverIP;Database=DBname;user id=user;password=password;OPTION=3"

vik999
10-06-2009, 03:10 PM
thnx for the reply
im getting now:


Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/oooo/home_page.asp, line 78, column 35
objAdapter1.Fill(objDataset1, news)
----------------------------------^

Old Pedant
10-06-2009, 10:56 PM
Just exactly what the error says.

FILL there is a SUB, not a function. You have two choices:

' as the message says, do *NOT* use parentheses:
objAdapter1.Fill objDataset1, news

' or force the SUB to be used like a function:
Call objAdapter1.Fill(objDataset1, news)

Old Pedant
10-06-2009, 10:58 PM
OH FOR CRYING OUT LOUD!

*NONE* of that code will COME CLOSE to working!

You are using VB.NET code and the .NET framework. That is, you are coding as if you are writing ASP.NET code!

But then you tried to use ASP (old style, pre-ASP.NET) to run the page.

NO NO NO.

This code is *NOT* for use with ASP and VBScript.

PERIOD.

It *IS* for use with ASP.NET and VB.NET.