Showing posts with label base. Show all posts
Showing posts with label base. Show all posts

Wednesday, March 28, 2012

Invalid syntax near nvarchar

Im trying to update and modify data in a grid view in my sql data base. I keep getting this error..What is the solution to this. Sorry, I have no programing experience. All help will be greatly appreciated. thank you
jdslim

Incorrect syntax near 'nvarchar'.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.

Source Error:

An unhandled exception was generated during the execution of thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3244
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +186
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1121
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +407
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +493
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +915
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +179
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1140
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +835
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +162
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +107
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +175
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3840

It would help if you posted your code.

|||

Here is the new stack trace and the code that goes with it. I started a new page that just contains the gridview and the sql data source.

Stack Trace:

[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.] 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.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147 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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +392 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +638 System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +71 System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +933 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1152 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +191 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919

<%

@.PageLanguage="VB" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

scriptrunat="server">

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><div> <asp:SqlDataSourceID="SqlDataSource1"runat="server"ConflictDetection="CompareAllValues"ConnectionString="<%$ ConnectionStrings:ConnectionString %>"DeleteCommand="DELETE FROM [Trials] WHERE [Trial#] = @.original_column1 AND [Wet Date] = @.original_Wet_Date AND [Check Date] = @.original_Check_Date AND [Comments] = @.original_Comments"InsertCommand="INSERT INTO [Trials] ([Trial#], [Wet Date], [Check Date], [Comments]) VALUES (@.column1, @.Wet_Date, @.Check_Date, @.Comments)"OldValuesParameterFormatString="original_{0}"SelectCommand="SELECT * FROM [Trials]"UpdateCommand="UPDATE [Trials] SET [Wet Date] = @.Wet_Date, [Check Date] = @.Check_Date, [Comments] = @.Comments WHERE [Trial#] = @.original_column1 AND [Wet Date] = @.original_Wet_Date AND [Check Date] = @.original_Check_Date AND [Comments] = @.original_Comments"><DeleteParameters><asp:ParameterName="original_column1"Type="String"/><asp:ParameterName="original_Wet_Date"Type="DateTime"/><asp:ParameterName="original_Check_Date"Type="DateTime"/><asp:ParameterName="original_Comments"Type="String"/></DeleteParameters><UpdateParameters><asp:ParameterName="Wet_Date"Type="DateTime"/><asp:ParameterName="Check_Date"Type="DateTime"/><asp:ParameterName="Comments"Type="String"/><asp:ParameterName="original_column1"Type="String"/><asp:ParameterName="original_Wet_Date"Type="DateTime"/><asp:ParameterName="original_Check_Date"Type="DateTime"/><asp:ParameterName="original_Comments"Type="String"/></UpdateParameters><InsertParameters><asp:ParameterName="column1"Type="String"/><asp:ParameterName="Wet_Date"Type="DateTime"/><asp:ParameterName="Check_Date"Type="DateTime"/><asp:ParameterName="Comments"Type="String"/></InsertParameters></asp:SqlDataSource></div><asp:GridViewID="GridView1"runat="server"AllowSorting="True"AutoGenerateColumns="False"DataKeyNames="Trial#"DataSourceID="SqlDataSource1"Style="z-index: 100; left: 538px; position: absolute; top: 391px"><Columns><asp:CommandFieldShowDeleteButton="True"ShowEditButton="True"/><asp:BoundFieldDataField="Trial#"HeaderText="Trial#"ReadOnly="True"SortExpression="Trial#"/><asp:BoundFieldDataField="Wet Date"HeaderText="Wet Date"SortExpression="Wet Date"/><asp:BoundFieldDataField="Check Date"HeaderText="Check Date"SortExpression="Check Date"/><asp:BoundFieldDataField="Comments"HeaderText="Comments"SortExpression="Comments"/></Columns></asp:GridView></form>

</

body>

</

html>|||

Hi

I just want to check if you ever solved the problem? I'm sitting with the same thing, but nothing will work...

I've tried the suggestions made, but it still doesn't work.

|||

Hi

I just want to check if you ever solved the problem? I'm sitting with the same thing, but nothing will work...

I've tried the suggestions made, but it still doesn't work.

|||you are better off starting a new thread and post your codes there

Wednesday, March 21, 2012

Invalid object name

Hi Folks,

Need a bit of help with a problem I'm having:

ODBC Error Code = S0002 (Base table not found)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
'UsersVsPages'.

SQL = "delete from Pages Where Page_Key = 147"

The above error message is returned when running a piece of code. The
table "UsersVsPages" that can't be found did exist but I dropped it
when it became unnecessary. I also set up a diagram with cascading
deletes etc. This is where I'm guessing the problem originates but
having looked through the relationships of "Pages" I have been unable
to find any reference to "UsersVsPages".

Can anyone point me in the right direction?

Thanks

Dave A."David Armstrong" <ukprototype@.yahoo.com> wrote in message
news:307ccadf.0407070835.7934080f@.posting.google.c om...
> Hi Folks,
> Need a bit of help with a problem I'm having:
> ODBC Error Code = S0002 (Base table not found)
> [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
> 'UsersVsPages'.
>
> SQL = "delete from Pages Where Page_Key = 147"
>
> The above error message is returned when running a piece of code. The
> table "UsersVsPages" that can't be found did exist but I dropped it
> when it became unnecessary. I also set up a diagram with cascading
> deletes etc. This is where I'm guessing the problem originates but
> having looked through the relationships of "Pages" I have been unable
> to find any reference to "UsersVsPages".
> Can anyone point me in the right direction?
>
> Thanks
> Dave A.

Another possibility might be a trigger which still references the old table.
If that's not the case, you could use Profiler to watch the SQL sent to the
server, to make sure it's really executing what you think it is.

Simon|||Thanks very much Simon, it was a trigger. Being new to MSSQL I wasn't
aware of this feature. Again thanks for the help.

Dave A.

"Simon Hayes" <sql@.hayes.ch> wrote in message news:<40ec33b7$1_3@.news.bluewin.ch>...
> "David Armstrong" <ukprototype@.yahoo.com> wrote in message
> news:307ccadf.0407070835.7934080f@.posting.google.c om...
> > Hi Folks,
> > Need a bit of help with a problem I'm having:
> > ODBC Error Code = S0002 (Base table not found)
> > [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
> > 'UsersVsPages'.
> > SQL = "delete from Pages Where Page_Key = 147"
> > The above error message is returned when running a piece of code. The
> > table "UsersVsPages" that can't be found did exist but I dropped it
> > when it became unnecessary. I also set up a diagram with cascading
> > deletes etc. This is where I'm guessing the problem originates but
> > having looked through the relationships of "Pages" I have been unable
> > to find any reference to "UsersVsPages".
> > Can anyone point me in the right direction?
> > Thanks
> > Dave A.
> Another possibility might be a trigger which still references the old table.
> If that's not the case, you could use Profiler to watch the SQL sent to the
> server, to make sure it's really executing what you think it is.
> Simon

Friday, March 9, 2012

Invalid authorization specification

Hi:

I'm trying to connect to a data base of "sql server 2005 enterprise" named BCR.
The server name is "server1"
I'm using Windows Authentication to connect to server
The operating system is Windows Server 2003 Enterprise Edition Service Pack 1

When I run the aspx I get this error at line 21

System.Data.OleDb.OleDbException: Invalid authorization specification Invalid connection string attribute at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at ASP.pruebaLeeSqlServer_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) in Z:\Digital\pruebaLeeSqlServer.aspx:line 21

This is my code:

Dim str2 As String = "Provider=SQLNCLI; Server = server1; Database = BCR"
Dim cnn2 As OleDbConnection = New OleDbConnection(str2)
Dim cmd2 As New OleDbCommand()
Dim drd2 As OleDbDataReader
Try
cnn2.Open()
cmd2.Connection = cnn2''''line 21
cmd2.CommandText ="SELECT LastName FROM Employees"
drd2 = cmd2.ExecuteReader
Do While drd2.Read
%>
<%=drd2.GetString(0)%><br>
<%
Loop
drd2.Close()
Catch exc1 As Exception
%>
<%=exc1.ToString()%>
<%
Finally
cnn2.Close()
End Try

What could be wrong?
Do I need enable permission for asp.net in sql server?
how I can do it?

Thanks!!

You should be using the objects in the System.Data.SqlClient namespace to connect to MS SQL Server, not System.Data.OleDb. That should fix your issue given that there is no problem with your connection string.

HTH,
Ryan

|||thanks Ryan. It works!

I are right, I had to use System.Data.SqlClient namespace instead of System.Data.OleDb. And I just change my connection string to

"Server=server1; Database=BCR; Trusted_Connection=True;"

Thanks!