Showing posts with label newbie. Show all posts
Showing posts with label newbie. Show all posts

Monday, March 26, 2012

Invalid object name while reading data out of an SQL Database

Hi all,
I'm a complete newbie on ASP.Net.

I want to get some data out of a SQLserver Database running on my system with SQL Server 2005 Express. The name of the Database is 'tempdb' and the table is called "Members". the SQLServer runs as Local System with the Windows account.

When I try to open the site, I always get the same error:
Invalid object name 'Members'

I don't know what to do anymore. I read a post, where anybody set the rights for the owner, but my database is running with the Windows account.

Here is the Code of the page so far:

<%@. Page Language="VB" Debug="True" Strict="True" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SQlClient" %>
<script runat="server">
Sub Page_Load (ByVal Sender As Object, _
ByVal E As EventArgs)

Dim connStr As String
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
connStr += "database=tempdb;"
connStr += "Truster_Connection=yes"
Dim conn As New SQLConnection(connStr)
conn.Open()

Dim sql As String
sql = "SELECT COUNT (*) FROM Members"
Dim cmd As New SQLCommand(sql, conn)
Dim ergebnis As String
ergebnis = cmd.ExecuteScalar().toString()
Dim t As String
t = "Die Tabelle Members hat " & _
ergebnis & " Zeilen. <br>" & _
"Das Kommando lautet: " & _
cmd.CommandText & "<br>" & _
"Der Kommandotyp ist: " & _
cmd.CommandType

ausgabe.innerHTML = t

End Sub
</script>
<html><head><title>
Demo zu SQLCommand.ExecuteScalar
</title></head>
<body>
<h3>Demo zu SQLCommand.ExecuteScalar</h3>
<p runat="server" id="ausgabe" />
</body></html>

Thanks for your help an sorry for my english.

Greets
Flash_Prince

The problem is objects in tempdb is valid for limited time so your object the Member table does not exist. Microsoft provided the tempdb for SQL Server to be used to proccess complex queries and test queries so when you create a table if you did not drop it SQL Server will drop it at some point. Try the links below to download sample databases you can create and use with SQL Server 2005. The databases comes with tables but you can create your own tables so you can add the member table to any of the three database. Hope this helps.


http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034&displaylang=en

http://www.microsoft.com/downloads/details.aspx?FamilyID=e719ecf7-9f46-4312-af89-6ad8702e4e6e&DisplayLang=en

|||

The problem is, that i want to use the database without entering the path of the database file in the sourcecode. When I use the nordwind database, all the sql queries are working very well. But if I use the Nordwind Database, I only know to connect by OleDB.

Can you tell me how to use a database in the way decribed above with a sql connection?

I hope, this is described understandable, cause my english is not the best.

|||

You need to create connection string and most of the information you need is covered in the two links below. Hope this helps.

http://www.connectionstrings.com

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000010.asp

|||The problem is in your connection string. You have a typo: "Truster_Connection=yes" should be "Trusted_Connection=yes".

Friday, March 23, 2012

Invalid object name 'db_student.myuser.tbl_studentname'.

HI, i am a newbie of SQL server.
What I got is an error shown as the title in which an ASP file made the SQL
call.
The script is just as follow:
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_cia_STRING
'Recordset1.Source = "SELECT * FROM fund WHERE studentno='k01' and remark
='confirm' ORDER BY date DESC"
Recordset1.Source = "db_aia..po_student_socre 'K01',' ',1"
Recordset1.CursorType = 1
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
I am sure that the procedure po_student_score exist and have set the execute
permission for the user with username myuser.
How can I solve the problem?
Thank you very much.
Hi,
First see the spelling of the procedure, the SCORE is spelled as SOCRE..
Recordset1.Source = "db_aia..po_student_socre 'K01',' ',1"
Thanks
Hari
MCDBA
<blue> wrote in message news:%231E%23aCUmEHA.1672@.TK2MSFTNGP14.phx.gbl...
> HI, i am a newbie of SQL server.
> What I got is an error shown as the title in which an ASP file made the
> SQL
> call.
> The script is just as follow:
> set Recordset1 = Server.CreateObject("ADODB.Recordset")
> Recordset1.ActiveConnection = MM_cia_STRING
> 'Recordset1.Source = "SELECT * FROM fund WHERE studentno='k01' and
> remark
> ='confirm' ORDER BY date DESC"
> Recordset1.Source = "db_aia..po_student_socre 'K01',' ',1"
> Recordset1.CursorType = 1
> Recordset1.CursorLocation = 2
> Recordset1.LockType = 3
> Recordset1.Open()
> I am sure that the procedure po_student_score exist and have set the
> execute
> permission for the user with username myuser.
> How can I solve the problem?
> Thank you very much.
>

Monday, March 19, 2012

Invalid Directory error message

Hi,

I am a newbie to integrating of asp page to crystal report. Please assist me in what error I am making.

From asp page, I would like to click on "Request Reports" button and it goes to ViewReports.asp

Within ViewReports.asp, I have the following code.

<%@. LANGUAGE="VBSCRIPT" %>
<title>Crystal Reports ASP Example - Displaying a Simple Report</title>
<%
reportname = "wwwroot\aspect\CommissionStatement2006.rpt"
%>

<!-- #include file="AlwaysRequiredSteps.asp" -->
<!-- #include file="MoreRequiredSteps.asp" -->
<!-- #include file="SmartVieweractivex.asp" -->

<%
strPeriod = Request.form("Period")
strReport = Request.Form("crystalradio")

Response.Write strPeriod
Response.Write "<br>"
Response.Write strReport

%>

<HTML>
<HEAD></HEAD>
<TITLE>View Reports</TITLE>

<BODY>
</BODY>
</HTML>

-----

Error I get is:

Error Type:
Crystal Reports ActiveX Designer (0x80043AC4)
Invalid directory.
/scripts/padmaja/AlwaysRequiredSteps.asp, line 56

Now the path of my report is

wwwroot\aspect\wwwroot\aspect\CommissionStatement2006.rpt

Line 56 of AlwaysRequiredSteps.asp is

Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)

Any ideas.

Thanks.I get this error because my reports are in another directory while my asp pages are in one directory. If I move the CR reports to the same directory as my ASP pages, then it works fine.

But any ideas as to how I can configure my path of the report in ASP pages?

'path of the report is wwwroot\merge\
strReport = Request.Form("crystalradio")
'reportname = "\merge\" & strReport
'Response.write reportname

reportname = "CommissionStatement2006.rpt"