Thursday, March 29, 2012
Error loading report
Error in file e:\directory\report.rpt.
Failed to load database information.
Any ideas.?
ThanksMake sure it is pointing the correct database|||Check if proper DSN is created and Verify the Database in the report at design time.|||With e:\ being the network drive my report e:\myreport.rpt is pointing to e:\myreport.xsd
which is correct as far as I know.|||Have ttried changing network paths to UNC, no joy.
Strangely, if I load the project within VB.Net, the app and the reports run fine. But when I run the installed package I get this error. This makes me think that maybe I need to package up some additional files with the app.?
Tuesday, March 27, 2012
Error installing SQL Server 2005 Express Manager
My name is Pete and I'm new to this forum. Today, I installed Microsoft .Net Framework 2.0 and SQL Server 2005 Express June CTP. The following error pops up when I attempt to install SQL Server 2005 Express Manager:
"The installer encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2755"I've downloaded this package several times and reinstalled it with no such luck.
Did anyone experience this same problem when you tried to install SQL Server Express Manager?
Thank you for your answers
PeterHi Pete,
I suggest you try downloading the package again. We've had a couple of reports similar to this.
Dan|||Hello Dan,
I downloaded and installed this package several times with no such luck. Below is the acutal text of the error:
"The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2755"The following URL is the source of the package:
http://www.microsoft.com/downloads/details.aspx?FamilyId=C7A5CC62-EC54-4299-85FC-BA05C181ED55&displaylang=en
If you can point me in the right direction as to where I can get a 'working' copy of this package, then that would be great.
Thank you for your answers.
Peter|||
Hi Dan,
I was able to successfully install SQL Server 2005 Express Manager. The resolution was to copy to the ExpressManager.msi file to the local disk, such as C:, then install it. It didn't work when I tried to install it from a network and or UNC name.
Pete
Sunday, March 11, 2012
Error in Programming DTS using VB.net
Hi ,
i am using VS.NET 2003 for programming and SQL sever 2005 is my database.
while creating DTS packages,
i am using code as follows
Public Sub Task_Sub4(ByVal goPackage As Object)
Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup
Dim oCustomTask4 As DTS.DataPumpTask2
oTask = CType(goPackage, DTS.Package).Tasks.New("DTSExecuteSQLTask")
oCustomTask4 = CType(oTask.CustomTask, DTS.DataPumpTask2)
oCustomTask4.Name = "Copy Data from contact_info to [content_shriya].[dbo].contact_info] Task"
oCustomTask4.Description = "Copy Data from contact_info to [content_shriya].[dbo].[contact_info] Task"
oCustomTask4.SourceConnectionID = 3
oCustomTask4.SourceSQLStatement = "select * from [Content_management].[dbo].[contact_info]"
oCustomTask4.DestinationConnectionID = 4
oCustomTask4.DestinationObjectName = "[content_shriya].[dbo].[contact_info]"
oCustomTask4.ProgressRowCount = 1000
oCustomTask4.MaximumErrorCount = 0
oCustomTask4.FetchBufferSize = 1
oCustomTask4.UseFastLoad = True
oCustomTask4.InsertCommitSize = 0
oCustomTask4.ExceptionFileColumnDelimiter = "|"
oCustomTask4.ExceptionFileRowDelimiter = vbCrLf
oCustomTask4.AllowIdentityInserts = False
oCustomTask4.FirstRow = 0
oCustomTask4.LastRow = 0
oCustomTask4.FastLoadOptions = 2
oCustomTask4.ExceptionFileOptions = 1
oCustomTask4.DataPumpOptions = 0
'Call oCustomTask4_Trans_Sub1(oCustomTask4)
goPackage.Tasks.Add(oTask)
oCustomTask4 = Nothing
oTask = Nothing
End Sub
But i am geeting error in line
oCustomTask4 = CType(oTask.CustomTask, DTS.DataPumpTask2)
giving error 'System.InvalidCastException'
Additional information: Specified cast is not valid.
i changed it with oCustomTask4 = oTask.CustomTask ,
then also similar error appear.
Please solve my problem, i need to create DTS Packages by using VS.NET 2003 and Database is SQL server 2005.
Thank you
You might have better success posting this in the DTS forum.
I'm not an expert in DTS programming, but since you created oTask as an ExecuteSQLTask, I don't think you can cast it to a DataPumpTask. You need to create it as a DataPumpTask.
|||
Thank you Jhon the code works.
|||Mark the response that was helpful as an answer, please. It helps with searching in the forum.Wednesday, March 7, 2012
Error in INSERT INTO
I'm sure that this is quite a simple program. I am generating an INSERT INTO statement in the Query builder (!) of Visual Basic .NET, and I consistantly get the following error: "Missing semi-colon at the end of the end of the SQL statement." The SQL stat
ement in question is:
INSERT INTO tblBlocks
(ActualTotalHoles, Block_Name, BlockComment, ChargedHoles, PlannedTotalHoles, Site_Name)
VALUES (?, ?, ?, ?, ?, ?)
SELECT tblBlocks.Block_Name, tblBlocks.Site_Name
FROM tblBlocks
WHERE (tblBlocks.Block_Name =?),( tblBlocks.Site_Name = ?);
Would much appreciate some help - Thanks.
It's being interpreted as two SQL statements, not one. The missing
semi-colon should come after VALUES(?, ?, ?, ?, ?, ?);
"Lite" <anonymous@.discussions.microsoft.com> wrote in message
news:C052EA2E-9424-4E0C-9D30-8FAFC93F064B@.microsoft.com...
> Hi,
> I'm sure that this is quite a simple program. I am generating an INSERT
INTO statement in the Query builder (!) of Visual Basic .NET, and I
consistantly get the following error: "Missing semi-colon at the end of the
end of the SQL statement." The SQL statement in question is:
> INSERT INTO tblBlocks
> (ActualTotalHoles, Block_Name, BlockComment,
ChargedHoles, PlannedTotalHoles, Site_Name)
> VALUES (?, ?, ?, ?, ?, ?)
> SELECT tblBlocks.Block_Name, tblBlocks.Site_Name
> FROM tblBlocks
> WHERE (tblBlocks.Block_Name =?),( tblBlocks.Site_Name = ?);
> Would much appreciate some help - Thanks.
Error in INSERT INTO
I'm sure that this is quite a simple program. I am generating an INSERT INTO
statement in the Query builder (!) of Visual Basic .NET, and I consistantly
get the following error: "Missing semi-colon at the end of the end of the S
QL statement." The SQL stat
ement in question is:
INSERT INTO tblBlocks
(ActualTotalHoles, Block_Name, BlockComment, ChargedHoles, PlannedTotalHoles
, Site_Name)
VALUES (?, ?, ?, ?, ?, ?)
SELECT tblBlocks.Block_Name, tblBlocks.Site_Name
FROM tblBlocks
WHERE (tblBlocks.Block_Name =?),( tblBlocks.Site_Name = ?);
Would much appreciate some help - Thanks.It's being interpreted as two SQL statements, not one. The missing
semi-colon should come after VALUES(?, ?, ?, ?, ?, ?);
"Lite" <anonymous@.discussions.microsoft.com> wrote in message
news:C052EA2E-9424-4E0C-9D30-8FAFC93F064B@.microsoft.com...
> Hi,
> I'm sure that this is quite a simple program. I am generating an INSERT
INTO statement in the Query builder (!) of Visual Basic .NET, and I
consistantly get the following error: "Missing semi-colon at the end of the
end of the SQL statement." The SQL statement in question is:
> INSERT INTO tblBlocks
> (ActualTotalHoles, Block_Name, BlockComment,
ChargedHoles, PlannedTotalHoles, Site_Name)
> VALUES (?, ?, ?, ?, ?, ?)
> SELECT tblBlocks.Block_Name, tblBlocks.Site_Name
> FROM tblBlocks
> WHERE (tblBlocks.Block_Name =?),( tblBlocks.Site_Name = ?);
> Would much appreciate some help - Thanks.
error in fetching data
Dim con As SqlConnection
con = New SqlConnection("Data Source=local;AttachDbFilename='D:\New Folder\horus\horus.mdf';Integrated Security=True")
Dim cmd As New String("SELECT TOP (10) serial, name, gender, dateofbirth FROM(dbo.students)ORDER BY RAND(CONVERT(varbinary(4), NEWID()))")
Dim cd As SqlDataAdapter
cd = New SqlDataAdapter(cmd, con)
Dim ds As New DataSet()
cd.Fill(ds, "students")
grid.DataSource = ds.Tables("students").DefaultView
grid.DataBind()
that code is selecting random records from the database and showing it in grid the error is in the cd.fill(ds,"students") line so can any one help me in that problem.thanksAre you sure your query (SQL) statement is valid? I've never seen RAND() specified in ORDER BY clause before. ORDER BY clause usually requires a list of column names. Did you try running the query in MS-SQL directly to see if it works?|||
No, the SQL statement isn't valid, there must be some kind of language barrier here because I've pointed that out twice before, but not because of the RAND(). You can't put your table names in parenthesis like that.
Wrong:
Dim cmd As New String("SELECT TOP (10) serial, name, gender, dateofbirth FROM(dbo.students)ORDER BY RAND(CONVERT(varbinary(4), NEWID()))")
Right:
Dim cmd As New String("SELECT TOP (10) serial, name, gender, dateofbirth FROM dbo.students ORDER BY RAND(CONVERT(varbinary(4), NEWID()))")
|||hello Motley that code is not showing anything as i said in the other topic, anyway i have another code that serch for name and also not working hope u tell me what is the error in that line :("SELECT tserial,name,subjectname,stage,class FROM teachers WHERE name =' &TextBox1.Text'&", con)
thanks|||
You should change to use parameterized queries in order to avoid SQL Injection attacks.
This will "fix" your problem, but leave a huge security hole in your application:
("SELECT tserial,name,subjectname,stage,class FROM teachers WHERE name='" &TextBox1.Text&"'", con)
Note that that is name, equals, single quote, double quote, ampersand, Textbox1.text, ampersand, double quote, single quote, double quote.
|||hello, ok that code is ok i have another code problem i have two dropdownlist the first one has the name of the tables in my database the second one has a value in column in all these tables the problem is the server cant get the table name from the dropdownlist here is the code :Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydb.mdf;Integrated Security=True;User Instance=True")
Dim com As New SqlDataAdapter("SELECT * FROM " & ddl1.SelectedValue & "WHERE class = " & ddl2.SelectedValue, con)
Dim ds As New DataSet()
com.Fill(ds, ddl1.SelectedValue)
grid.DataSource = ds.Tables(ddl1.SelectedValue).DefaultView
grid.DataBind()
the table name is in the value of the dropdownlist by the way this a periods tables for a school and every stage has three classes so the column class is in all the tables, hope u can help thanks.|||no one can help?!!! i'm close to finish the site hope u can help.|||Try assigning the SELECT statement into a string variable to verify whether or not there is any syntax error. Also, try out the hard-coded string to make sure the SQL works in the first place. Finally, unless your "class" column is an integer type, you should quote the value using single quotes.|||hello jcasp i tried what u told me the sql statement is alright but the problem is in that dropdown list i typed its value as the name of the table but it doesnt work i tried to put single quotes in that line "WHERE class = " & 'ddl2.SelectedValue', con) i put ddl2.selectedvalue between the single quotes but it put a blue line under the & so hope u can help and by the way the class is not integer it's varchar, hope u can help me soon i'm really close to do it.|||hey guys i just need a little help to make it, i'm waiting ur replies.|||To enclose the value in single quotes, the syntax should be:
"WHERE class ='" & ddl2.SelectedValue & "'", con)
|||
Bad design. Move all the class tables into a single table with a column that has a class name column. Then do this:
Dim conn as new SqlCommand("{Connecting String here}")
conn.open
Dim cmd as new SqlCommand("SELECT * FROM MyClassTable WHEREClassName=@.ClassName AND Class=@.Class",conn)
cmd.parameters.add("@.ClassName",sqldbtype.varchar).Value=ddl1.Selectedvalue
cmd.parameters.add("@.Class",sqldbtype.varchar).Value=ddl2.SelectedValue
dim ds as new DataSet()
dim com as new sqldataadapter(cmd)
com.fill(ds,"MyClassTable")
grid.Datasource=ds.Tables(0).DefaultView
grid.Databind
Sunday, February 26, 2012
Error in DataList test query - sqlserver
Error in DataList test query - sqlserver
I found some vs 2005 asp.net walkthroughs.
The first I tried required Northwind.
But sqlserver 2005 came with AdventureWorks, so I used that instead.
I followed the walkthrough instructions, dragging a DataList to Design, and clicking the smart tag to configure my datasource.
sqldatasource=SqlDataSource1
connection string - Data Source=YOUR-02910F1DF1;Initial Catalog=AdventureWorks;Integrated Security=True
I tried the test query.
There was an error executing the query....
Invalid name '[Employee}
I tried the query builder, and then the second line is my own sql statement. Both produced the error above.
SELECT [EmployeeID], [Title] FROM [Employee]
SELECT [EmployeeID], [Title] FROM Employee
I tried this with several different tables, all producing the same error.
When I do with with an access database with an access datasource, it works fine. But since I really want to put something on the web, I need sqlserver 2005.
I confirmed that sqlserver.exe was running.
Can somebody help me?
dennist685
I'd really appreciate an answer to this question. I can't go very far in web applications if I can't attach a datasource to a DataList.dennist685|||
I got an answer from of all places, the 2003 newsgroups.
Hi Dennist685,
Welcome to ASPNET newsgroup.
From your description, when you try creating a data-driven page in ASP.NET
2.0/VS.NET 2005, you always get error on test query, yes?
Based on my experience, the VS.NET 2005 will use configuration wizard to
help create Sql query statements for our SqlDataSource control. Are you
following the wizard to configure the datasoruce? We can first confirm that
the SqlDataSource is configured correctly. We can open the aspx after
configured the sqldatasource control and check the sql query statement
embeded (test in SQLServer's query console/analyzer to see whether it
works....).
After the SqlDataSource is configured OK, we can then attach it to the
DataList control so as to displaying data.
BTW, for Northwind and Pubs databases, we can manually copy their mdf file
from the original SQLServer 2000 and manually attach them into SQLServer
2005. Also, VS.NET 2005/ .net 2.0 support sqlserver 7.0 2005 (also
include a SQLExpress edition which replace the original MSDE). So please
feel free to use either of them for your data store.
If there're anything unclear or need any further help, please feel free to
post here.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thank you Steven,
I never got as far as configuring the datasource correctly.
There was an error executing the (test) query. Please check the syntax of the command and if present, the types and values of the parameters to be sure they are correct.
Invalid name 'Employee'
There is no stack trace. I was in the configuration stage where the wizard asks you to perform a test query.
I went ahead and built default.aspx successfully,
But when I tried to view it in a browser, I got the stack trace you wanted.
Server Error in '/FormatDataList' Application.
--
Invalid object name 'Employee'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Employee'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Invalid object name 'Employee'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
System.Data.SqlClient.SqlDataReader.get_MetaData() +62
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +294
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +20
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +107
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +10
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1657
System.Web.UI.WebControls.BaseDataList.GetData() +53
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +267
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +57
System.Web.UI.WebControls.BaseDataList.DataBind() +62
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +55
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +62
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5729
--
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
dennist685
hank you for the detailed response Dennis,
After tested through your further description, I've reproduce the problem
you encountered. Yes, when using the SqlDataSource's configuration wizard
to generate select statement by "specify columns from a table or view", the
generated SQL statement always cause Error.
And based on my further research, I think this should be a problem of the
SqlDataSource control's configuration wizard. Because for SQL 2005 tables,
they could be grouped by a new unit called "Schema", so when we reference a
table in our SQLStatement , we can not simply use their tablename, but need
to add the schema name together . for example, in our problem, the
Adventureworks database's Employee table are in a schema named
"HumanResources", then, our sql statement should be
"SELECT HumanResources.Employee.* FROM HumanResources.Employee"
or "SELECT * FROM HumanResources.Employee"
rather than "Select * from Employee", "HumanResources" is the schema name.
And seems the SqlDataSource control's
"specify columns from a table or view" wizard dosn't support this
correctly. I'll report this issue to our product team. Curently, I suggest
you try the following means to workaround this problem when dealing with
the SQL2005 database tables:
1. We can manually adjust the sql statement in web page (aspx )'s template
by adding the Schema name before the table name.
2. Instead of using the "specify columns from a table or view" in the
wizard, we can choose another option
"specify a custom SQL statement or stored procedure"
in this wizard, we can use another SQL statement generating tool (Query
Builder ) to auto generate the sql statement (which will correctly add the
Schema name for SQL 2005 data tables based on my tests). Or we can manually
enter sqlstatement also.
Anyway, since this is a problem of our product , I'm sorry for the
inconvenience it brings you. Thanks for your understanding.
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven,
thank you every so much for the time you spent tracing down the bug. Frankly, I'm very disappointed in Visual Studio for this and other problems, especially in asp.net 2.0.
Also thank you for solving the problems.
There are also problems I found with other asp.net walkthroughs, but those I found easy ways around.
I find it interesting that the people in Microsoft asp.net forums and Microsoft technical forums couldn't answer the question, and you people, still concentrating of vs 2003, did.
dennist685
I don't understand why the common logic was not used - i.e., as long as the name is unque you don't have to qualify it.
Arie|||There's still a problem. The query builder doesn't support WHERE and other clauses. So I guess we have to use the table name and type in the schema qualifier.
It's really disappointing. I don't see how the visual studio team overlooked something so glaring. I imagine in the advanced areas there are bugs galore.
I'd bet SP1 is coming soon.
dennist685
Error in DataList test query - sqlserver
Error in DataList test query - sqlserver
I found some vs 2005 asp.net walkthroughs.
The first I tried required Northwind.
But sqlserver 2005 came with AdventureWorks, so I used that instead.
I followed the walkthrough instructions, dragging a DataList to Design, and clicking the smart tag to configure my datasource.
sqldatasource=SqlDataSource1
connection string - Data Source=YOUR-02910F1DF1;Initial Catalog=AdventureWorks;Integrated Security=True
I tried the test query.
There was an error executing the query....
Invalid name '[Employee}
I tried the query builder, and then the second line is my own sql statement. Both produced the error above.
SELECT [EmployeeID], [Title] FROM [Employee]
SELECT [EmployeeID], [Title] FROM Employee
I tried this with several different tables, all producing the same error.
When I do with with an access database with an access datasource, it works fine. But since I really want to put something on the web, I need sqlserver 2005.
I confirmed that sqlserver.exe was running.
Can somebody help me?
dennist685
I'd really appreciate an answer to this question. I can't go very far in web applications if I can't attach a datasource to a DataList.dennist685|||
I got an answer from of all places, the 2003 newsgroups.
Hi Dennist685,
Welcome to ASPNET newsgroup.
From your description, when you try creating a data-driven page in ASP.NET
2.0/VS.NET 2005, you always get error on test query, yes?
Based on my experience, the VS.NET 2005 will use configuration wizard to
help create Sql query statements for our SqlDataSource control. Are you
following the wizard to configure the datasoruce? We can first confirm that
the SqlDataSource is configured correctly. We can open the aspx after
configured the sqldatasource control and check the sql query statement
embeded (test in SQLServer's query console/analyzer to see whether it
works....).
After the SqlDataSource is configured OK, we can then attach it to the
DataList control so as to displaying data.
BTW, for Northwind and Pubs databases, we can manually copy their mdf file
from the original SQLServer 2000 and manually attach them into SQLServer
2005. Also, VS.NET 2005/ .net 2.0 support sqlserver 7.0 2005 (also
include a SQLExpress edition which replace the original MSDE). So please
feel free to use either of them for your data store.
If there're anything unclear or need any further help, please feel free to
post here.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thank you Steven,
I never got as far as configuring the datasource correctly.
There was an error executing the (test) query. Please check the syntax of the command and if present, the types and values of the parameters to be sure they are correct.
Invalid name 'Employee'
There is no stack trace. I was in the configuration stage where the wizard asks you to perform a test query.
I went ahead and built default.aspx successfully,
But when I tried to view it in a browser, I got the stack trace you wanted.
Server Error in '/FormatDataList' Application.
--
Invalid object name 'Employee'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Employee'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Invalid object name 'Employee'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
System.Data.SqlClient.SqlDataReader.get_MetaData() +62
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +294
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +20
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +107
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +10
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1657
System.Web.UI.WebControls.BaseDataList.GetData() +53
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +267
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +57
System.Web.UI.WebControls.BaseDataList.DataBind() +62
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +55
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +62
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5729
--
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
dennist685
hank you for the detailed response Dennis,
After tested through your further description, I've reproduce the problem
you encountered. Yes, when using the SqlDataSource's configuration wizard
to generate select statement by "specify columns from a table or view", the
generated SQL statement always cause Error.
And based on my further research, I think this should be a problem of the
SqlDataSource control's configuration wizard. Because for SQL 2005 tables,
they could be grouped by a new unit called "Schema", so when we reference a
table in our SQLStatement , we can not simply use their tablename, but need
to add the schema name together . for example, in our problem, the
Adventureworks database's Employee table are in a schema named
"HumanResources", then, our sql statement should be
"SELECT HumanResources.Employee.* FROM HumanResources.Employee"
or "SELECT * FROM HumanResources.Employee"
rather than "Select * from Employee", "HumanResources" is the schema name.
And seems the SqlDataSource control's
"specify columns from a table or view" wizard dosn't support this
correctly. I'll report this issue to our product team. Curently, I suggest
you try the following means to workaround this problem when dealing with
the SQL2005 database tables:
1. We can manually adjust the sql statement in web page (aspx )'s template
by adding the Schema name before the table name.
2. Instead of using the "specify columns from a table or view" in the
wizard, we can choose another option
"specify a custom SQL statement or stored procedure"
in this wizard, we can use another SQL statement generating tool (Query
Builder ) to auto generate the sql statement (which will correctly add the
Schema name for SQL 2005 data tables based on my tests). Or we can manually
enter sqlstatement also.
Anyway, since this is a problem of our product , I'm sorry for the
inconvenience it brings you. Thanks for your understanding.
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven,
thank you every so much for the time you spent tracing down the bug. Frankly, I'm very disappointed in Visual Studio for this and other problems, especially in asp.net 2.0.
Also thank you for solving the problems.
There are also problems I found with other asp.net walkthroughs, but those I found easy ways around.
I find it interesting that the people in Microsoft asp.net forums and Microsoft technical forums couldn't answer the question, and you people, still concentrating of vs 2003, did.
dennist685
I don't understand why the common logic was not used - i.e., as long as the name is unque you don't have to qualify it.
Arie|||There's still a problem. The query builder doesn't support WHERE and other clauses. So I guess we have to use the table name and type in the schema qualifier.
It's really disappointing. I don't see how the visual studio team overlooked something so glaring. I imagine in the advanced areas there are bugs galore.
I'd bet SP1 is coming soon.
dennist685
Friday, February 24, 2012
Error in Calling Stored Procedure
I want to call a stored procedure in ASP.Net 2.0. I've already made sure that the SP contains no error by the Query Analyzer.
However, when I try to run this in the ASP.Net application, error occured.
This error message is {"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."}
Calling the SP via a Class
1Public Function ExecuteStoredProcedure(ByVal NameAs String,ByVal Para()As String,ByVal Value()As String)2If Para.Length <> Value.LengthThen Exit Function3 SqlCmd =New SqlCommand4 SqlCmd.Connection = SqlConn5 SqlCmd.CommandText = Name6 SqlCmd.CommandType = CommandType.StoredProcedure7For iAs Integer = 0To Para.Length - 18'SqlCmd.Parameters.AddWithValue(Para(i), Value(i))9Dim pAs New SqlParameter(Para(i), SqlDbType.NVarChar)10 p.Direction = ParameterDirection.Input11 p.Value = Value(i)12 SqlCmd.Parameters.Add(p)13Next14 SqlCmd.ExecuteNonQuery()15End Function
The Code behind file
1Protected Sub btnSubmit_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnSubmit.Click2If txtFromDate.Text =""OrElse txtToDate.Text =""Then3 trMsg.Visible =True4 Exit Sub5 End If67 Dim tsAs New Thread(AddressOf GenerateReport)8 ts.Start()910 MultiView1.ActiveViewIndex = 111 lblConfirmationMessage.Text ="Report generating in progress." & vbNewLine &"You can continue using other functions."12End Sub1314 Protected Sub GenerateReport()15Dim userNameAs String =CType(Session("User"), clsUser).UserName16Dim fromAs String = txtFromDate.Text1718Dim connAs New clsConnector19 conn.OpenConnection()20'conn.Insert("EXEC gen_report '" + txtReportName.Text + "','" + txtDescription.Text + "','" + userName + "','" + txtFromDate.Text + "','" + txtToDate.Text + "';")21 conn.ExecuteStoredProcedure("gen_report", _22New String() {"@.name","@.remark","@.by","@.fromdate","@.todate"}, _23New String() {txtReportName.Text, txtDescription.Text, userName, txtFromDate.Text, txtToDate.Text})24 conn.CloseConnection()25End Sub26
Thanks!
Are u saving Date as string into a column with data type smalldatetime. In your code it seams that you r passing date value . Can u check this one.
|||try to set timeout to bigger value
SqlCmd =New SqlCommand
4 SqlCmd.Connection = SqlConn
5 SqlCmd.CommandText = Name
sqlcmd.CommandTimeout=300
and maybe it will help, how long it take to create results for this procedure in Query analyzer? your timeout should be a little longer than this time.
|||The data type is "datetime".
And I use the Now.ToString("yyyy-MM-dd HH:mm:ss") for passing the value.
|||So definitely it won't work. Try to pass it as a date object into the database. Moreover if your conversion of date in different format other than the one defined in db wil create error even if you pass data as dateobject. So try to pass data into DB in the relevent datatype itself|||Actually, all the input parameter in the SP is nvarchar, but in different size. So, I use String in the code-behind file.
I also tried to set the connection timeout to 300, but the error message is still the same as the original one.
|||did you tried to run the sp directly in query analyzer by passing the parameters you are passing from UI?
thanks,
satish.
|||I've just tried to run the SP in the query analyzer and in the UI using the same set of parameters. It works in the query analyzer but not in the UI.
Also, the error is not due to the Thread. Because I tried to run the GenerateReport() without using the Thread and the same error occured.
One more point to mentioned is that I've set the timeout period to 300 seconds in the connection string, however, the UI show me that error message within 1 minute. Is that really timeout?
Thanks
|||Hello,
Most likely, the Sql Connection problem to me.
Have you tried to debug step by step?
I don't feel good with this line on your function:
SqlCmd.Connection = SqlConn
Why don't you get the all the code from other class into your calling page, and debug it?
Just opinion!
|||here i write some sample of stored procedure
i think this will help u
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("Project1connectionString").ToString())
con.Open()
Dim DA As New SqlDataAdapter("select acceptqty,itemid from grndetail where grnid='" & Trim(ggrnid) & "'", con)
Dim ds As New DataSet
DA.Fill(ds)
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1 Step 1
Dim cmd1 As New SqlCommand
cmd1.CommandText = "aaceptqtygrn"//name of stored procedure
cmd1.CommandType = CommandType.StoredProcedure
cmd1.Connection = con
cmd1.Parameters.AddWithValue("@.itemId", ds.Tables(0).Rows(i).Item("itemid"))
cmd1.Parameters.AddWithValue("@.acceptqty", ds.Tables(0).Rows(i).Item("acceptqty"))
cmd1.ExecuteNonQuery()
Next
con.Close()
Hi yipych,
I have tried your code and its working for me. I think its the problem with your connection string or some other connection related issues. I have placed the sample code here.
http://www.igold.in/forum/samples/WebVb100.zip
Let me know if it helps you
Error in building SQL query within "LIKE" statement for TableAdapter in Design Section
ASP.net 2.0 (VB), SQL Server 2005:
While creating a new TableAdapter in design section, I'm using the query builder and trying to write a query within "LIKE" statement as below -
Example1: SELECT * FROM table WHERE field LIKE @.'%TextBoxData%'
Example2: SELECT * FROM table WHERE field LIKE'%@.TextBoxData%'
but these query doesn't work...error in building query...any clue to make it work? If I remove "@." sure the query will work with normal but '%TextBoxData%' will become a hardcoding value...this is not I want...I want make the TextBoxData become a flexible value depend on the data what I enter in my text box like 'abc,123' not like 'TextBoxData'...
I know normally it supposed to be like:
"SELECT * FROM table WHERE field LIKE'%" & TextBoxData.Text & "%'"
It can work when inCode Section, but not at this time...because now i'm trying to made it with "Query Builder" for TableAdapter " inDesign Section...hmm did you get what I mean? Sorry for my bad english
Thanks in advance
Hi, you can use such query which should beinterpreted correctly as T-SQL command:
SELECT * FROM table WHERE field LIKE '%'+TextBoxData+'%'|||
Nice work, how thanksIori_Jay, you are the man