Click to See Complete Forum and Search --> : Problem with opening MSSQL database, please help


omaral
October 7th, 2005, 09:42 AM
Hi all,

I'm writing a small application using VB 6.0 and MsSql server Dev 2000. However I have no problem with accessing Database, I get

[ODBC sql server driver][sql server] could not find stored procedure "ItemInfo"

highlighting on following line.


rsMyRS.Open "ItemInfo", dbMyDB, adOpenDynamic, adLockOptimistic

In case you need I attache part of my code.

Dim dbMyDB As ADODB.Connection
Dim rsMyRS As ADODB.Recordset

Set dbMyDB = New ADODB.Connection
Set rsMyRS = New ADODB.Recordset
dbMyDB.Open "CustInfo"
rsMyRS.Open "ItemInfo", dbMyDB, adOpenDynamic, adLockOptimistic

rsMyRS.AddNew
...


Is anyone could help me?

Thank you,

omaral

srinika
October 7th, 2005, 09:50 AM
What is ItemInfo ?

A table ? If so that part should be
rsMyRS.Open "Select * from ItemInfo" , dbMyDB, adOpenDynamic, adLockOptimistic

If its a Stored procedure, u should have such

Srinika

erickwidya
October 7th, 2005, 09:58 PM
rsMyRS.Open "ItemInfo", dbMyDB, adOpenDynamic, adLockOptimistic, adCmdTable

try to added the red code..coz the default is adCmdText but u passing it as TableName

omaral
October 16th, 2005, 06:30 AM
Thank you erickwidya. Your comment helped me. It is working now.
Thanks Srinika for reply.

Omaral

sagesh
October 19th, 2005, 02:53 AM
Hi all,

I'm writing a small application using VB 6.0 and MsSql server Dev 2000. However I have no problem with accessing Database, I get

[ODBC sql server driver][sql server] could not find stored procedure "ItemInfo"

highlighting on following line.


rsMyRS.Open "ItemInfo", dbMyDB, adOpenDynamic, adLockOptimistic

In case you need I attache part of my code.

Dim dbMyDB As ADODB.Connection
Dim rsMyRS As ADODB.Recordset

Set dbMyDB = New ADODB.Connection
Set rsMyRS = New ADODB.Recordset
dbMyDB.Open "CustInfo"
rsMyRS.Open "ItemInfo", dbMyDB, adOpenDynamic, adLockOptimistic

rsMyRS.AddNew
...


Is anyone could help me?

Thank you,

omaral

The below given is the correct code:

'##########
'For Displaying:

Dim dbMyDB As ADODB.Connection
Dim rsMyRS As ADODB.Recordset
Dim strSql as string

Set dbMyDB = New ADODB.Connection
Set rsMyRS = New ADODB.Recordset

dbMyDB.Open "CustInfo"
strSql = "Select * from ItemInfo "
rsMyRS.Open strSql, dbMyDB, adOpenStatic, adLockOptimistic


'##########
'For Adding:

Dim dbMyDB As ADODB.Connection
Dim rsMyRS As ADODB.Recordset
Dim strSql as string

Set dbMyDB = New ADODB.Connection
Set rsMyRS = New ADODB.Recordset

dbMyDB.Open "CustInfo"

strsql = "INSERT INTO tablename myField1,myField2 VALUES(myValue1,myValue2)

dbMyDB.Execute strSql



'##########
'For Updating/Editing:

Dim dbMyDB As ADODB.Connection
Dim rsMyRS As ADODB.Recordset
Dim strSql as string

Set dbMyDB = New ADODB.Connection
Set rsMyRS = New ADODB.Recordset

dbMyDB.Open "CustInfo"

strsql = "UPDATE Tablename SET myField1 = myValue1, myField2=myValue2 WHERE myField=myCondition"

dbMyDB.Execute strSql



'##########
'For Deletion:

Dim dbMyDB As ADODB.Connection
Dim rsMyRS As ADODB.Recordset
Dim strSql as string

Set dbMyDB = New ADODB.Connection
Set rsMyRS = New ADODB.Recordset

dbMyDB.Open "CustInfo"

strsql = "DELETE FROM Tablename WHERE myField=myCondition"

dbMyDB.Execute strSql


################

I hope the above given will be helpful for you. If you still have doubt, do post a reply.