Can't get data

S

Steven K

OK, I'm stumped.

I am getting the error: Exception Details:
System.Data.OleDb.OleDbException: Syntax error or access violation

on the last line (spBusinessUnit = cmdBusinessUnit.ExecuteReader()) when
trying to connect to a SQL Server 2K machine (this works with ASP):

<%@ Page Language="VB" Explicit="True" Debug="True"%>
<%@ import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>

Dim strConn As String
Dim cnnSearch As OleDbConnection
strConn = "Provider=SQLOLEDB;Data Source=MyServer;Initial
Catalog=MyDatabase;User ID=MyUser;Password=MyPswd;"
cnnSearch = New OleDbConnection(strConn)
cnnSearch.Open()

Dim spBusinessUnit As OleDb.OleDbDataReader
Dim cmdBusinessUnit As New OleDb.OleDbCommand("sp_web_Search
'FindBusinessProduct','','',''", cnnSearch)
cmdBusinessUnit.CommandType = CommandType.StoredProcedure
spBusinessUnit = cmdBusinessUnit.ExecuteReader()
 
S

Stanley

Your OleDbCommand looks to be messed up. I am not sure if this is from
mistake in typeing or wrapping or what but it looks like you have way to
many parameters for the command object. As far as I know there are only 4
ways to do the command object.

New OleDbCommand()
OleDbCommand(CommandText)
OleDbCommand(CommandText, OleDbConnection)
OleDbCommand(CommandText, OleDbConnection, OleDbTransaction)

So for your code it should look like
Dim cmdBusinessUnit As New
OleDb.OleDbCommand("sp_web_SearchFindBusinessProduct", cnnSearch) 'watch for
wrap here it should be one line

Although I am not sure if your Sproc is actually called
"sp_web_SearchFindBusinessProduct".

-Stanley
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top