System.Data.SqlClient.SqlException: Syntax Error Converting The Varchar Value 'V' To A Column Of Data Type Int

Aug 31, 2006

 
I am using  a stored procedure which returns a value of charecter datatype 'V' to the calling program.I am getting an sql exception 
System.Data.SqlClient.SqlException: Syntax error converting the varchar value 'V' to a column of data type int
i didnot define any int datatype in my table
this is my code
SqlCommand com = new SqlCommand("StoredProcedure4", connection);
com.CommandType = CommandType.StoredProcedure;
 
 
SqlParameter p1 = com.Parameters.Add("@uname", SqlDbType.NVarChar);
SqlParameter p2 = com.Parameters.Add("@opwd", SqlDbType.NVarChar);
SqlParameter p3 = com.Parameters.Add("@role", SqlDbType.NVarChar);
p3.Direction = ParameterDirection.ReturnValue;
p1.Value = username.Text.Trim();
p2.Value = password.Text.Trim();
com.ExecuteReader();
lblerror2.Text = (string)(com.Parameters["@role"].Value);
can your figure out what is the error ? Is it a coding error or error of the databse

View 3 Replies


ADVERTISEMENT

System.Data.SqlClient.SqlException: Error Converting Data Type Numeric To Decimal.

Aug 31, 2004

Hi There,

I'm using C# to get a value for a DOUBLE precision variable, called "Length", from a textBox using the following line:

Length = Convert.ToDouble( txtLength.Text )

I'm also using the following lines to prepare my stored procedure call:

arParms[9] = new SqlParameter("@Length", SqlDbType.Decimal, 5);
arParms[9].Value = record.Length;

My stored procedure has the following parameter definition:

@Length decimal(9,3)

My problem is that if someone types a value bigger than 999999 in the textbox he will get for sure the following error:

System.Data.SqlClient.SqlException: Error converting data type numeric to decimal.

I don't know how to either make sql or C# to truncate the value or catch the exception to automatically assign 0 to the parameter.

Please Help.
Moshe

View 1 Replies View Related

Syntax Error Converting The Varchar Value '*' To A Column Of Data Type Int.

Oct 14, 2005

Hi,
This is my complete trigger.


ALTER TRIGGER DeleteTriggerC_Middleware_Exception ON dbo.C_Middleware_Exception AFTER DELETE AS
BEGIN
DECLARE @RowCount AS VARCHAR
SET @RowCount = @@ROWCOUNT

DECLARE @TableName_Deleted AS VARCHAR(50)
DECLARE @ErrorMsg_Deleted AS VARCHAR(255)
DECLARE @AddlErrMsg_Deleted AS VARCHAR(255)
DECLARE @SubjectArea_Deleted AS VARCHAR(25)
DECLARE @CHKPT_Deleted AS VARCHAR(10)

SELECT @TableName_Deleted = table_name , @ErrorMsg_Deleted = cast(error_msg AS varchar(255)) , @AddlErrMsg_Deleted = cast(addl_error_msg AS varchar(255)),
@SubjectArea_Deleted = cast(SUBJECT_AREA AS varchar(25)), @CHKPT_Deleted = cast(CHKPT AS varchar(255))FROM DELETED
--where subject_area = 'inventory'

UPDATE dbo.Error_Log SET No_Of_Occurance = No_Of_Occurance + @RowCount WHERE Table_Name = @TableName_Deleted
IF @@ROWCOUNT = 0
BEGIN
UPDATE dbo.Error_Log SET No_Of_Occurance = No_Of_Occurance + @RowCount WHERE @ErrorMsg_Deleted like Error_Msg and Subject_Area IS NULL and ChkPoint IS NULL
END
IF @@ROWCOUNT = 0
BEGIN
UPDATE dbo.Error_Log SET No_Of_Occurance = No_Of_Occurance + @RowCount WHERE @AddlErrMsg_Deleted like Addl_Error_Msg
END
IF @@ROWCOUNT = 0
BEGIN
UPDATE dbo.Error_Log SET No_Of_Occurance = No_Of_Occurance + @RowCount WHERE @ErrorMsg_Deleted like Error_Msg and Subject_Area = @SubjectArea_Deleted and ChkPoint = @CHKPT_Deleted
END

END


when i am executing the follwing query i am gettin systax error.

Query :delete from dbo.c_middleware_exception where subject_area = 'eap_room'

Error :
Server: Msg 245, Level 16, State 1, Procedure DeleteTriggerC_Middleware_Exception, Line 17
Syntax error converting the varchar value '*' to a column of data type int.


what could be the solution.

Thanks in advance
yvnsmca

View 1 Replies View Related

Syntax Error Converting The Varchar Value '10.136.20.20' To A Column Of Data Type Int.

Jul 20, 2005

I have an inventory database that Im trying to create a report out ofthe IP address are a lookup on a seperat table but I keep getting theabove error can I change the table row to something to fix this orwhat.SELECT i.INVENTORY_ITEM_ID AS [IP Address],i.HOST_NAME AS [ServerName], '' AS Flag, i.MEMO AS Comments, 'Seattle' AS City, 'Washington'AS State,CASE WHEN fv.value = 'EL EET1410' THEN '1111 3rdAve.' WHEN fv.value = 'EL WFL17' THEN '999 3rd Ave.' ELSE '' END AS[Address 1],' ' AS [Address 2], CASE WHEN fv.value = 'ELEET1410' THEN '1111' WHEN fv.value = 'EL WFL17' THEN '2222' ELSE ''END AS [Building ID],fv.VALUE AS Building, '98101' AS Zip,CASE WHEN fv.value = 'EL EET1410' THEN '14' WHENfv.value = 'EL WFL17' THEN '17' ELSE '' END AS [Computing FacilityLevel],CASE WHEN fv.value = 'EL EET1410' THEN '14' WHENfv.value = 'EL WFL17' THEN '17' ELSE '' END AS [Bldg Floor],CASE WHEN fv.value = 'EL EET1410' THEN 'C028'WHEN fv.value = 'EL WFL17' THEN 'C123' ELSE '' END AS WSPID,i.LOCATION_IN_FACILITY AS Location,i.SERIAL_NUMBER AS [Serial Number], i.ASSET_TAG AS [Asset Tag], ' ' AS[Second Asset Tag(s)],vv.VALUE AS Manufacture, mv.VALUE AS Model,'Yes' AS [Rack Mountable], rv.VALUE AS [Rack Units], 'DEV' AS [ServerEnviroment],lv.VALUE AS [Sever Type], ov.VALUE AS OS,CASE WHEN lv.value = 'Server - Intel Blade' THEN'Windows' WHEN lv.value = 'Server - Intel' THEN 'Windows' WHENlv.value = 'Server - Unix' THEN 'Unix'ELSE '' END AS [OS Type], '19x28' AS Footprint,ev.VALUE AS [Technical Owner of Server], 'N/A' AS [SLA Category],i.ON_BOARD_NIC_PORT_COUNT AS [NW Connectionquantity], 'Devlopment/Test Machine' AS [Application(s) Name],ev.VALUE AS [PW Contact],'N/A' AS RTO, 'N/A' AS RPO, 'No' AS [Is BoxClustered?], 'N/A' AS [Buisness Critical],CASE WHEN mv.value = 'Proliant DL580G1' THEN'90lbs' WHEN mv.value = 'Proliant DL360G2' THEN '85lbs' WHEN mv.value= 'Enterprise 220R' THEN'45lbs' ELSE '' END AS Weight,i.LAST_MODIFIED_DATE AS [Date of Last Install], 'No' AS [DedicatedCircuit]FROM dbo.INVENTORY_ITEM i LEFT OUTER JOINdbo.IP_TO_INVENTORY pv ON pv.IP_ADDRESS = i.INVENTORY_ITEM_IDLEFT OUTER JOINdbo.LOOKUP_VALUE lv ON lv.LOOKUP_VALUE_ID =i.DEVICE_TYPE_ID LEFT OUTER JOINdbo.LOOKUP_VALUE fv ON fv.LOOKUP_VALUE_ID =i.FACILITY_ID LEFT OUTER JOINdbo.LOOKUP_VALUE vv ON vv.LOOKUP_VALUE_ID =i.VENDOR_ID LEFT OUTER JOINdbo.LOOKUP_VALUE mv ON mv.LOOKUP_VALUE_ID =i.MODEL_ID LEFT OUTER JOINdbo.LOOKUP_VALUE ov ON ov.LOOKUP_VALUE_ID =i.SOFTWARE_VERSION_ID LEFT OUTER JOINdbo.LOOKUP_VALUE ev ON ev.LOOKUP_VALUE_ID =i.CHECKED_OUT_BY_ID LEFT OUTER JOINdbo.LOOKUP_VALUE rv ON rv.LOOKUP_VALUE_ID =i.U_HEIGHT_ID

View 2 Replies View Related

Syntax Error Converting The Varchar Value To A Column Of Data Type Int

Aug 29, 2007

SQL server 2000




Note : GRP_ID integer

declare @SchDnGRP VARCHAR(50)
SET @SchDnGRP='29,30'
SELECT USR_ID_ARY from AD_USR_GRP Where GRP_ID in(@SchDnGRP)




i got error like

Syntax error converting the varchar value '29,30' to a column of data type int.

if need any sql server Configuration requie, please advice to me

View 5 Replies View Related

Syntax Error Converting The Varchar Value 'a' To A Column Of Data Type Int

Feb 10, 2006

I have a table(tab1) with a column(col1) of type varchar. I insert a row with an integer value(1). And when i query the table using the sql, select col1 from tab1 where col1 = 1, it works fine.

But after i insert a varchar, say 'a' and then do the same query, i get an error message saying, "Syntax error converting the varchar value 'a' to a column of data type int.". Why is this so? Please reply.

View 11 Replies View Related

Syntax Error Converting The Varchar Value 'email' To A Column Of Data Type Int.

Nov 4, 2005

Well I am doing a simple insert through a stored procedure..., but I am getting this error. In my table I have the UserID as a VARCHAR 100. I am storing from a textbox that will have number because its there email. But I am not converting anything. Do I need to convert in this scenario?? 
Server Error in '/pickem' Application.


Syntax error converting the varchar value 'johndoe@hotmail.com' to a column of data type int. 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: Syntax error converting the varchar value 'johndoe@hotmail.com' to a column of data type int.Source Error:



Line 113:
Line 114: dbConnection.Open
Line 115: Dim Dr As System.Data.IDataReader = myCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Line 116:
Line 117: Dim rowsAffected As Integer = 0
Here is the code:             Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connString"))
             Dim myCommand as New SqlCommand("prcAddTeam", dbConnection)             myCommand.CommandType = CommandType.StoredProcedure
             myCommand.Parameters.Add("@UserID", SqlDbType.Varchar, 100).Value = TRIM(emailBox.Text)             myCommand.Parameters.Add("@TeamName", SqlDbType.Varchar, 40).Value = TRIM(teamBox.Text)             myCommand.Parameters.Add("@Address1", SqlDbType.Varchar, 50).Value = TRIM(addressBox.Text)             myCommand.Parameters.Add("@Address2", SqlDbType.Varchar, 50).Value = TRIM(address2Box.Text)             myCommand.Parameters.Add("@City", SqlDbType.Varchar, 50).Value = TRIM(cityBox.Text)             myCommand.Parameters.Add("@State", SqlDbType.Varchar, 30).Value = stateList1.SelectedItem.Value             myCommand.Parameters.Add("@Zip", SqlDbType.Varchar, 11).Value = TRIM(zipBox.Text)             myCommand.Parameters.Add("@FirstName", SqlDbType.Varchar, 50).Value = TRIM(firstNameBox.Text)             myCommand.Parameters.Add("@LastName", SqlDbType.Varchar, 50).Value = TRIM(lastnameBox.Text)
             dbConnection.Open             Dim Dr As System.Data.IDataReader = myCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
             Dim rowsAffected As Integer = 0
             dbConnection.OpenStored procedure:CREATE                  PROCEDURE prcAddTeam                 @UserID    VARCHAR(100)                ,@TeamName  VARCHAR(40)                ,@Address1  VARCHAR(50)                ,@Address2  VARCHAR(50)                ,@City      VARCHAR(50)                ,@State     VARCHAR(30)                ,@Zip       VARCHAR(11)                ,@FirstName VARCHAR(50)                ,@LastName  VARCHAR(50)   ASSET NOCOUNT ONDECLARE @ID   INTSET @ID = 0SELECT @ID = ISNULL((SELECT UserID from tblUserInfo      where UserID = @UserID),0)IF @ID = 0    BEGIN      INSERT INTO tblUserInfo (UserID,TeamName,Address1,Address2,City,State,Zip,FirstName,LastName,CreateDate)      VALUES(@UserID,@TeamName,@Address1,@Address2,@City,@State,@Zip,@FirstName,@LastName,GetDate())             SET @ID = @@IDENTITY      END

View 5 Replies View Related

A First Chance Exception Of Type 'System.Data.SqlClient.SqlException' Occurred In System.data.dll

Jan 18, 2008

Hi,
I've written this code multiple times now. But for the first time i get an error at the line underlined. My procedure runs perfectly when i execute it through Sql Query analyzer.
plzz help.. Its urgent and am unable to find the reason for this error "A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll"
Thanks !SqlConnection conn = new SqlConnection(DbConnectionString);
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "dbo.rqryTradesPRR";
cmd.Parameters.Add("@COBDate",SqlDbType.DateTime).Value = "2002-10-31 00:00:00.000" ;
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
// have written something here

}
 Thanks in advance !
 

View 2 Replies View Related

System.Data.SqlClient.SqlException: Incorrect Syntax Near '&>'.

Mar 8, 2008

I keep getting this error whenever I try to run my query:   System.Data.SqlClient.SqlException: Incorrect syntax near '>'.
I'm just trying to fill a  dataset with three tables that contain the past few days headlines...what am I doing wrong?? Private Sub fishHeadlines()
Dim dateNow As DateTime = DateTime.Now()Dim dateThen As DateTime = DateTime.Today.AddDays(-2)
'create the table array so we can create the sql statement in a moment
Dim table() As Stringtable = New String() {"Snapper", "Scissor", "MahiMahi"}
Dim strSelect As String
'Create a dataset to hold the tables containing the headlinesDim headlinesDS As New DataSet()
'create the connection string - SnapshotConnectionString is in web.config file
Dim strConnect As StringstrConnect = ConfigurationManager.ConnectionStrings("fishConnectionString").ConnectionString
'create a connection object to the databaseDim objConnect As New SqlConnection(strConnect)
objConnect.Open()
Dim i As Integer
'fill the datatablesFor i = 0 To table.Length
strSelect = "SELECT Event FROM " & table(i) & "WHERE (DateOfEntry > '" & dateThen & "')"
'create a data adapter object using connection and sql statementsDim objDA1 As New SqlDataAdapter(strSelect, objConnect)
'fill the dataset
objDA1.Fill(headlinesDS, table(i))
Next
Dim strTable As StringDim dr As DataRow
strTable = "<table>"For i = 0 To table.Length
For Each dr In headlinesDS.Tables(table(i)).Rows
strTable += "<tr><td>" & dr(0).ToString() & "</td></tr>"
Next
Next
strTable += "</table>"
'display the data
lblHeadlines.Text = strTable
End Sub

View 2 Replies View Related

System.Data.SqlClient.SqlException: The Conversion Of A Char Data Type To A Datetime Data Type Resulted In An Out-of-range Datetime Value.

Dec 14, 2005

After testing out the application i write on the local pc. I deploy it to the webserver to test it out. I get this error.

System.Data.SqlClient.SqlException: The conversion of a char data type to a
datetime data type resulted in an out-of-range datetime value.

Notes: all pages that have this error either has a repeater or datagrid which load data when page loading.

At first I thought the problem is with the date, but then I can see
that some other pages that has datagrid ( that has a date field) work
just fine.

anyone having this problem before?? hopefully you guys can help.

Thanks,

View 4 Replies View Related

System.Data.SqlClient.SqlException: Incorrect Syntax Near The Keyword 'Plan'.

May 2, 2005

I'm having Some Problem with my code....Whenever i try to insert from using a Insert button page gives me this error
"System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'Plan'."
Can somebody help me What's the Problem...for your convenience i'm giving my code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
        End If
End Sub
Sub doInsert(Source as Object, E as EventArgs)
Dim myConn As SqlConnection = New SqlConnection(strConn)Dim MySQL as string = "Insert into Activities (ActDate, Activity, Plan, Completed) values (@ActDate, @Activity, @Plan, @Completed);"
        Dim Cmd as New SQLCommand(MySQL, MyConn)
        cmd.Parameters.Add(New SQLParameter("@ActDate", Textbox2.Text))        cmd.Parameters.Add(New SQLParameter("@Activity", Label5.TExt))        cmd.Parameters.Add(New SQLParameter("@Plan", Textbox3.text))        cmd.Parameters.Add(New SQLParameter("@Completed", Textbox4.text))      ' cmd.Parameters.Add(New SQLParameter("@Comments", Text11.text))        MyConn.Open()        cmd.ExecuteNonQuery()
        BindData()        MyConn.Close()        label12.text = "Your data has been received!"    ' else    '    label12.text = "Data Already Enter For This Item-Name for This Date"
    ' end ifEnd Sub

View 2 Replies View Related

System.Data.SqlClient.SqlException: SSL Security Error

May 15, 2007

Hello,
we have asp.net apps on a windows 2003 server that connect to an instance of sql server 2005 enterprise edition on another windows 2003 server.  We get this error at random times.  Anyone know what could be causing it?
 
System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.Data.SqlClient.SqlException: SSL Security error.   at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)   at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)   at System.Data.SqlClient.SqlConnection.Open()Thanks

View 1 Replies View Related

Strange SQL Error System.Data.SqlClient.SqlException

May 1, 2008

Hi there, i copied some insert code from one page to another and it keeps throwing me this error, i was wondering if anyone can help me out. Here is the error
System.Data.SqlClient.SqlException: The name "Credit" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Admin_expenses.Button1_Click(Object sender, EventArgs e) in d:hostingmemberashdfhtdocswwwAdminexpenses.aspx.cs:line 40
 This is my code, i cant see anything obvious and as i said i just copied it across, the only things changed were the names and the sqlstringprotected void Button1_Click(object sender, EventArgs e)
{decimal intamount = Convert.ToDecimal(txtAmount.Text);
string sConnectionStringExpense = "Data Source=xxxx;Initial Catalog=xxxx;User ID=xxxx;Password=xxxx";SqlConnection objConnExpense = new SqlConnection(sConnectionStringExpense);
 using (objConnExpense)
{
objConnExpense.Open();string sqlExpense = "INSERT INTO tbl_expenses (expense_amount, expense_payment_type, expense_type, expense_description) " +
"VALUES (" + intamount + "," + ddlPaymentType.SelectedItem + "," + ddlExpenseType.SelectedValue + "," + txtDescription.Text + ")";SqlCommand objCmdExpense = new SqlCommand(sqlExpense, objConnExpense);
try
{
objCmdExpense.ExecuteNonQuery();
}catch (Exception ex)
{lblcomplete.Text = "!!Adjust stock for product at location " + Convert.ToString(ex);
}
finally
{
objConnExpense.Close();
}
}

View 6 Replies View Related

System.Data.SqlClient.SqlException: SSL Security Error

May 15, 2007

Hello,

we have asp.net apps on a windows 2003 server that connect to an instance of sql server 2005 enterprise edition on another windows 2003 server. We get this error at random times. Anyone know what could be causing it?



System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.Data.SqlClient.SqlException: SSL Security error.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
Thanks

View 4 Replies View Related

Error: System.Data.SqlClient.SqlException: Timeout Expired.

Apr 8, 2008

Hi,
    I am getting an time out expired error while import dbf files to the database.. In this upload one file had 379 records.. and it inserts it into the few tables and then i get the above error..in my event viewer.
 Error: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
No Changes made to the Plan table.
Inserting records(s) in Plan table.
No Changes made to Plan table.
Updating changes to PlanStatementInfo.
Updated 1 record(s) in PlanStatementInfo.
Inserting new records into PlanStatementInfo.
No new records were added to PlanStatementInfo.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, String spName, Object[] parameterValues)
at icc.BaseClasses.DL.DLImportPlan.Import(Int32 ClientId, Int32 PeriodId, Int32 UserId) in C:Documents and SettingsMy DocumentsPlanStatementsImportDLDLImportPlan.cs:line 116

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.cs:line 116 --this is where i am calling my sproc...  
 any help will will appreciated
Thanks,
Karen

View 4 Replies View Related

System.Data.SqlClient.SqlException: An Error Has Occurred While Establishing A Connection To The Server.

Mar 27, 2008

Is it possible to connect to an Access database on my local drive, or does it have to an SQL database? Here is the error I am getting: 
Server Error in ' 'Application.


An error has occurred while establishing a connection to the server.
 When connecting to SQL Server 2005, this failure may be caused by the fact that
under the default settings SQL Server does not allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified) 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: An error has occurred while establishing
a connection to the server.  When connecting to SQL Server 2005, this failure
may be caused by the fact that under the default settings SQL Server does not
allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error
Locating Server/Instance Specified)Source Error:



Line 19: Dim ConString As String = ("Data Source=C:Inetpubwwwrootmessage.mdb")Line 20: Dim myDataAdapter As New SqlDataAdapter(SQLStatement.Text, ConString)Line 21: myDataAdapter.Fill(myDataSet, "tblMessage")Line 22: myDataGrid.DataSource = myDataSet.Tables("tblMessage")Line 23: myDataGrid.DataBind()

View 2 Replies View Related

Getting Server Error Syntax Error Converting The Nvarchar Value 'Sonoma' To A Column Of Data Type Int.

Apr 20, 2007

Hi, all
I'm getting this error at runtime when my page tries to populate a datagrid. Here's the relevant code.
First, the user selects his choice from a dropdownlist, populated with a sqldatasource control on the aspx side:<asp:SqlDataSource ID="sqlDataSourceCompany" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [PayrollCompanyID], [DisplayName] FROM [rsrc_PayrollCompany] ORDER BY [DisplayName]">
</asp:SqlDataSource>
 And the dropdown list's code:<asp:DropDownList ID="ddlPayrollCompany" runat="server" AutoPostBack="True" DataSourceID="sqlDataSourcePayrollCompany"
DataTextField="DisplayName" DataValueField="PayrollCompanyID">
</asp:DropDownList>
Then, I use the selectedindexchanged event to bind the data to the datagrid. Here's that code:
 1 Sub BindData()
2
3 Dim ds As New DataSet
4 Dim sda As SqlClient.SqlDataAdapter
5 Dim strSQL As String
6 Dim strCon As String
7
8 strSQL = "SELECT [SocialSecurityNumber], [Prefix], [FirstName], [LastName], [HireDate], [PayrollCostPercent], " & _
9 "[Phone], [BadgeNumber], [IsSupervisor], [SupervisorID], [IsUser], [IsScout] FROM [rsrc_Personnel] " & _
10 "WHERE ([PayrollCompanyID] = @PayrollCompanyID)"
11
12 strCon = "Data Source=DATASOURCE;Initial Catalog=DATABASE;User ID=USERID;Password=PASSWORD"
13
14 sda = New SqlClient.SqlDataAdapter(strSQL, strCon)
15
16 sda.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@PayrollCompanyID", Me.ddlPayrollCompany.SelectedItem.ToString()))
17
18 sda.Fill(ds, "rsrc_Personnel")
19
20 dgPersonnel.DataSource = ds.Tables("rsrc_Personnel")
21 dgPersonnel.DataBind()
22
23 End Sub
24

 
I'm assuming my problem lies in line 16 of the above code. I've tried SelectedItemIndex, SelectedItemValue too and get errors for those, as well.
What am I missing?
Thanks for anyone's help!
Cappela07

View 2 Replies View Related

SQL Server 2012 :: Determine Which Column Is Causing Error Converting Data Type Varchar To Numeric?

Aug 14, 2014

I'm moving data from one database to another (INSERT INTO ... SELECT ... FROM ....) and am encountering this error:

Msg 8114, Level 16, State 5, Line 6
Error converting data type varchar to numeric.

My problem is that Line 6 is:

set @brn_pk = '0D4BDE66347C440F'

so that is obviously not the problem and my query has almost 200 columns. I can go through one by one and compare what column is int in my destination table and what is varchar in my source tables, but that could take quite a while. How I can work out what column is causing the problem?

View 3 Replies View Related

System.Data.SqlClient.SqlException :( -- Please Help

Feb 19, 2004

Hi All,

I am new to ASP.NET and trying to learn. I am getting the problem when I try to insert data into SQL. The exception that I am getting is

Exception Details: System.Data.SqlClient.SqlException: An explicit value for the
identity column in table 'Customers' can only be specified when a column list is used and IDENTITY_INSERT is ON.

My table name is 'Customers' and its as below.
-----------------------------------------------------------------------
CustomerID--numeric---Identity Seed is 1000---Identity Increment is 1---No Nulls.
Name--------varchar---No Nulls.
address------Varchar---No Nulls.
State--------Varchar---No Nulls.
Zip-----------VarcHar---No Nulls.
PhoneNumber-Varchar---No Nulls.
Email---------Varchar---No Nulls.

and my code is (No fun of my code please--I am a learner)
-----------------------------------------------------------------------

Imports System.Data

Imports System.Data.SqlClient

Public Class register

Inherits System.Web.UI.Page

Protected WithEvents cnNWind As SqlConnection

'Protected drCustomers As SqlDataReader

Protected WithEvents lbladd As System.Web.UI.WebControls.Label

Protected WithEvents lblState As System.Web.UI.WebControls.Label

Protected WithEvents lblcity As System.Web.UI.WebControls.Label

Protected WithEvents lblzip As System.Web.UI.WebControls.Label

Protected WithEvents lblPhone As System.Web.UI.WebControls.Label

Protected WithEvents lblEmail As System.Web.UI.WebControls.Label

Protected WithEvents TxtName As System.Web.UI.WebControls.TextBox

Protected WithEvents txtAdd As System.Web.UI.WebControls.TextBox

Protected WithEvents txtState As System.Web.UI.WebControls.TextBox

Protected WithEvents txtCity As System.Web.UI.WebControls.TextBox

Protected WithEvents txtZip As System.Web.UI.WebControls.TextBox

Protected WithEvents txtPhone As System.Web.UI.WebControls.TextBox

Protected WithEvents TxtEmail As System.Web.UI.WebControls.TextBox

Protected WithEvents BtnSubmit As System.Web.UI.WebControls.Button

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click

cnNWind = New SqlConnection()

cnNWind.ConnectionString = "Data Source=(local); Initial Catalog=cart; Integrated Security=SSPI"

cnNWind.Open()

If cnNWind.State = ConnectionState.Open Then

Dim cmCustomers As New SqlCommand("INSERT INTO Customers VALUES ('',' " & TxtName.Text & "','" & txtAdd.Text & "','" & txtState.Text & "','" & txtZip.Text & "','" & txtPhone.Text & "','" & TxtEmail.Text & "')", cnNWind)

cmCustomers.ExecuteNonQuery()

cmCustomers.ExecuteNonQuery()

cnNWind.Close()

End If

End Sub

End Class

The Error I am getting:
-----------------------------------------------------------------------
Server Error in '/SCart' Application.
--------------------------------------------------------------------------------

An explicit value for the identity column in table 'Customers' can only be specified when a column list is used and IDENTITY_INSERT is ON.
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: An explicit value for the identity column in table 'Customers' can only be specified when a column list is used and IDENTITY_INSERT is ON.

Source Error:


Line 46: If cnNWind.State = ConnectionState.Open Then
Line 47: Dim cmCustomers As New SqlCommand("INSERT INTO Customers VALUES ('','" & TxtName.Text & "','" & txtAdd.Text & "','" & txtState.Text & "','" & txtZip.Text & "','" & txtPhone.Text & "','" & TxtEmail.Text & "')", cnNWind)
Line 48: cmCustomers.ExecuteNonQuery()
Line 49: cnNWind.Close()
Line 50: End If


Source File: d:inetpubwwwrootSCart
egister.aspx.vb Line: 48

Stack Trace:


[SqlException: An explicit value for the identity column in table 'Customers' can only be specified when a column list is used and IDENTITY_INSERT is ON.]
System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
SCart.register.BtnSubmit_Click(Object sender, EventArgs e) in d:inetpubwwwrootSCart
egister.aspx.vb:48
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573


The code works fine If I Dont use Identity Column, But I need to use Identity Column in my Project :( ...Please Help.

View 4 Replies View Related

System.Security.SecurityException: Request For The Permission Of Type 'System.Data.SqlClient.SqlClientPermission, System.Data

Aug 21, 2006

I have created a windows library control that accesses a local sql database

I tried the following strings for connecting

Dim connectionString As String = "Data Source=localhostSQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true"

Dim connectionString As String = "Data Source=localhostSQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"



I am not running the webpage in a virtual directory but in

C:Inetpubwwwrootusercontrol

and I have a simple index.html that tries to read from an sql db but throws

the error

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,

etc etc

The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.SqlClient.SqlClientPermission
The Zone of the assembly that failed was:
Trusted


I looked into the .net config utility but it says unrestricted and I tried adding it to the trusted internet zones in ie options security

I think that a windows form connecting to a sql database running in a webpage should be simple

to configure what am I missing?

View 28 Replies View Related

Question About System.Data.SqlClient.SqlException

Apr 14, 2007

 I'm trying to retrieve an image from my ms sql server 2005, and i'm using VS2005....however, i have the following error during the compilation process  Code in webform2.aspx.vb:Partial Class webform2    Inherits System.Web.UI.Page    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        Dim connstr As String = "Data Source=DCPRJ007SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True"        Dim cnn As New Data.SqlClient.SqlConnection(connstr)        Dim cmd As New Data.SqlClient.SqlCommand("select * from dbo.images where id=" & Request.QueryString("id"), cnn)        cnn.Open()        Dim dr As Data.SqlClient.SqlDataReader = cmd.ExecuteReader()        Dim bindata() As Byte = dr.GetValue(1)        Response.BinaryWrite(bindata)    End SubEnd Class    System.Data.SqlClient.SqlException was unhandled by user code  Class=15  ErrorCode=-2146232060  LineNumber=1  Message="Incorrect syntax near '='."  Number=102  Procedure=""  Server="DCPRJ007SQLEXPRESS"  Source=".Net SqlClient Data Provider"  State=1  StackTrace:       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()       at System.Data.SqlClient.SqlDataReader.get_MetaData()       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)       at System.Data.SqlClient.SqlCommand.ExecuteReader()       at webform2.Page_Load(Object sender, EventArgs e) in C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005WebSitesWebSite7webform2.aspx.vb:line 10       at System.Web.UI.Control.OnLoad(EventArgs e)       at System.Web.UI.Control.LoadRecursive()       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

View 4 Replies View Related

System.Data.SqlClient.SqlException - When Inserting Image

Jul 13, 2006

Hi All,
I have a form (asp website with the default.aspx and default.aspx.cs) which I use to connect to the SQL Server 2005 database and insert, update,get and delete data to and from it. In the table I have a column called Picture to insert a photo (usually bmp files) which I declared as a varbinary(max). ID is the primary key and is an int (i tried it to be numeric & varchar).
I am trying to insert data into the table using a form with this syntax:
SqlConnection enter_conn = new SqlConnection("user id=;" +
"password=;server=servername;" +
"Trusted_Connection=yes;" +
"database=Member Profiles; " +
"connection timeout=30");
enter_conn.Open();
string insertSql = "Insert dbo.Details(ID,Last_Name,First_Name,Middle_Initial,Project, Organization,Manager,Current_Skills,Biography,Hobbies, Picture) Select 1001, 'ABC','XYZ','R',' Website Development','ACT',LKM','ASP.Net, C#.Net, SQL Server 2005, SharePoint, Java, ',' developing the new website for ACT using SharePoint and SQL Server 2005', ' Singing, Listening to Music, Dancing, Cooking, Swimming', BulkColumn from Openrowset( Bulk 'C:\photos\rose.bmp', Single_Blob) as Picture";


SqlCommand myCommand = new SqlCommand(insertSql, enter_conn);
int i = myCommand.ExecuteNonQuery();
 
 I have no data in the table and am doing the first insert. Though the data gets inserted I am getting this exception:
System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_Details'. Cannot insert duplicate key in object 'dbo.Details'. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at _Default.Enter_Click(Object sender, EventArgs e) in c:Documents and SettingskrkondaXMy DocumentsVisual Studio 2005WebSitesMember ProfilesDefault.aspx.cs:line 82
 
Can someone please suggest anything???? I appreciate a quick response please!!!!
 
Thanks,
Kavya

View 1 Replies View Related

System.Data.SqlClient.SqlException: Invalid Object Name

Dec 19, 2006

I am getting this error message 
System.Data.SqlClient.SqlException: Invalid object name 'RacingHeritage'
I have noticed from other posts where the database owner is the login name
I rebuilt the table and the owner is now dbo
Here is the Code 
   Function GetCustomers() As System.Data.DataSet        Dim connectionString As String = Application("HiddenConnection")        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
        Dim queryString As String = "SELECT [RacingHeritage].[RHID], [RacingHeritage].[UserID], [RacingHeritage].[Clie"& _            "ntFirstName] FROM [RacingHeritage]"        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand        dbCommand.CommandText = queryString        dbCommand.Connection = dbConnection
        Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter        dataAdapter.SelectCommand = dbCommand        Dim dataSet As System.Data.DataSet = New System.Data.DataSet        dataAdapter.Fill(dataSet)
        Return dataSet    End Function
Any Ideas

View 3 Replies View Related

System.Data.SqlClient.SqlException: Specified SQL Server Not Found

Mar 9, 2004

Hi everybody,

We are developing Asp.Net Application in following environment.

Windows 2003
Dot Net 2003
SQL Server 2000

Problem :

We have team of four people. We made one machine as database server and rest of the people trying to connect to that database server. we are getting error "SQL server not found.".

We are using following string as a connection string.

"DATA SOURCE=192.292.7.105;DATABASE=xxx;User ID=xxx;password=xxxx"

We have tried same connection string with the VB.Net program. It is working fine.

But when we are trying same string in the web application. It is giving me the above mentioned error.

Can any one help me ?

Thanks is advance.


From

Jigar Shah

View 4 Replies View Related

System.Data.SqlClient.SqlException: Timeout Expired

Sep 2, 2005

I am getting the exception -System.Data.SqlClient.SqlException: Timeout expired.The timeout period elapsed prior to completion of the operation or the server is not respondingWhen I am executing the stored procedureHow to resolve this?

View 1 Replies View Related

System.Data.SqlClient.SqlException: Timeout Expired.

Dec 3, 2007

We have some big problems with our SQL Server 2000 database right now.
The code has not been changed for over halv an year and some days ago we started to get this error.





System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Both web and database server is running fine.
Any help is appreciated!

(We are now pretty sure that all errors occurs when we are doing inserts to the database.)

View 1 Replies View Related

System.Data.SqlClient.SqlException: Timeout Expired.

Jul 21, 2007

Hi there,



I am not sure it is the right forum. The Exception is thrown in C# app while saving a few databases. Small databases are being saved OK but this one has 12,934,142KB after the last backup. I am not even sure what the words "last backup" mean in this case. It is possible that is the size of the database from two months ago when first the problem appeared. Since then I've neglected backup being preoccupied with other problems although the database grew.



The backup is executed by this store procedure:

USE [hist_OHLC]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [dbo].[backUphist_OHLC]
AS
BEGIN
SET NOCOUNT ON;
ALTER DATABASE hist_OHLC SET RECOVERY FULL
BACKUP DATABASE hist_OHLC TO DISK = 'L:SQLServerBackupshist_OHLChist_OHLCFullRM.bak'
BACKUP LOG hist_OHLC TO DISK = 'L:SQLServerBackupshist_OHLChist_OHLCFullRM.log';
END


What can I do about it? What is the rational way of backing up databases of this size?



What is the rational way of maintaining databases of this size in SQLEXPRESS? Shall I perhaps break this database down into fragments?



The tables contain daily records, about 500 per day. I can conceivably create another database every month or so but it will be a hassle.



How can I increase the timeout?



I just repeated the backup. All databases have been saved except this last one--Imoved that backup operation down the chain to be the last one. One database with about 1.5GBytes was saved fine.



I checked the timeout it is 15 sec. One has not control over it in C#. It does not have a Set option.



15

MyHandler caught : Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

The backup or restore was aborted.



Thanks.

View 7 Replies View Related

System.Data.SqlClient.SqlException: Timeout Expired

Sep 26, 2007

Hello, we have a fairly large .NET application that uses MSSQL Server 2005 Express.

I am getting the following error loggged to our error log somewhat often:

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

IIS and MSSQL server are on the same box, and talk locally. The server box is NOT losing internet so that is not the problem.

What could be causing this? Is this because we don't have enough system resources on the server, meaning CPU, RAM? Or is it poorly written ASP.NET or missing configuration information in the web.config file?

Thanks for the insight.

View 3 Replies View Related

Request For The Permission Of Type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, Pu

Mar 12, 2008


I created a .net console application within which I connect to a sql server (not local) as follows,


string conn_str = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=QuantEquitySql;Data Source=server name";

SqlConnection conn = new SqlConnection(conn_str);

conn.Open();
.
Everything works fine when I run it from my computer. When I try to run it from a network share I get the following error,

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I am using Visual Studio 2005 and .Net framwork v2.0.50727.

Does anybody know a fix to this problem?

Thanks

View 3 Replies View Related

Cannot Open SQL DB Request For This Login. (System.Data.SqlClient.SqlException)

Feb 28, 2007

Hi guys,
Everything seems to be fine, can browse the DB from VS, Preview data works fine in dataset, and the page works fine before adding any SQL DB code.
I draged n dropped a new DropDownList, Bind it to an object from dataset. And when I want to run the page I get this error !!!

I appreciate any help.
Thanks, Mehdi

View 4 Replies View Related

System.Data.SqlClient.SqlException: Invalid Object Name 'MESSAGE'.

Jun 7, 2007

i was deleting a row from my gridview.this fail  ("System.Data.SqlClient.SqlException: Invalid object name 'MESSAGE'.")   consists what must i do ?My SQL query is "UPDATE    MESSAGESET              DELETIONSTATUSTO = 1,_LASTMODIFYDATE =getdate() WHERE     (_ID = @ID)"  

View 5 Replies View Related

System.Data.SqlClient.SqlException: Procedure Expects Parameter

Apr 25, 2008

I have a stored procedure to validate the data from the table
CREATE PROCEDURE [dbo].[proc_Validate_BLDG]
@BLDGData varchar(50),@output int OUTAS
BeginIf Exists (Select DISTINCT  GBC FROM ServerName.Database.dbo.Table where GBC = @BLDGData) begin set @output = 1  end
Else begin set @output = 0  end
return @output
endGO
Also, I have a function in my asp.net pages to call the stored procedure
Public Function BLDGLookup() As Integer
'Create a connectionDim objConn As SqlConnection
objConn = GetConnection()
'Create a command object for the query Dim objCommand As New SqlCommand("proc_Validate_BLDG", objConn)
objCommand.CommandType = CommandType.StoredProcedure
Dim param As SqlParameter = Nothing
Dim output As IntegerobjCommand.Parameters.AddWithValue("@BLDGData", strBLDGTextBox)param = objCommand.Parameters.Add("@output", SqlDbType.Int)
param.Direction = ParameterDirection.Output
Try
objCommand.ExecuteNonQuery()output = Int32.Parse(objCommand.Parameters("@output").Value.ToString())
Catch ex As ExceptionDim ex2 As Exception = ex
Dim errorMessage As String = String.EmptyWhile Not (ex2 Is Nothing)
errorMessage += ex2.ToString()
ex2 = ex2.InnerException
End While
Response.Write(errorMessage)
Finally
End TryReturn output
objConn.Close()
End Function
 However, when i put in code to call this function and return a value I am getting thsi error:
System.Data.SqlClient.SqlException: Procedure 'proc_Validate_BLDG' expects parameter '@BLDGData', which was not supplied.

View 1 Replies View Related

System.Data.SqlClient.SqlException: Login Failed For User

Aug 12, 2005

when i browser the page on browser the following error dispaly
" System.Data.SqlClient.SqlException: Login failed for user xxxx "sqlAdaptor , sqlconnection and dataSet are all fine. i can even preivew dataset, but i don't know while it doesn't display in browser.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved