Inserting Roles Error

Apr 25, 2006

Msg 515, Level 16, State 2, Procedure aspnet_Roles_CreateRole, Line 37

Cannot insert the value NULL into column 'RoleId', table 'PORTAL.MDF.dbo.aspnet_Roles'; column does not allow nulls. INSERT fails.

The statement has been terminated.

this MS sql server 2005 using the aspnetdb.mdf.

The RoleID is an primary key and supposed to be autopopulating itself everytime there is an new insertion correct? so what is the problem?

View 3 Replies


ADVERTISEMENT

Error While Calling The Roles.AddUserToRole (error Message: Cannot Resolve Collation Conflict For Equal To Operation)

Feb 5, 2006

Hi, I have developed a website in asp.net 2. I have tester it and it is working fine on my computer but when I have uploaded it to my server I'm getting an error message when the user signup. The error occurs when I'm setting the user role to 'members'.
 
Error line > Roles.AddUserToRole(user.UserName, "members")
 
The strage thig is that it is working on my computer but not on the server. My home computer and the server are running the same software versions and the website database is the same as well.
 
To double check that my code is not generating the error I have lonched 'SQL Query Analizer' and executed the folowing code on my database:
NOTE: In my database I have create the user “teeluk12� and a role “members�
 
aspnet_UsersInRoles_AddUsersToRoles "/", "teeluk12", "members", "5/02/2006 4:44:33 pm"
 
Once again the code is working on my home computer but not on the server. On the server I'm getting the following error:
 
Server: Msg 446, Level 16, State 9, Procedure aspnet_UsersInRoles_AddUsersToRoles, Line 76
Cannot resolve collation conflict for equal to operation.
 
 
 
Does anybody know what could cause the error?
Could it be some permissions that I didn't set on my server?
 
 
Thanks for my help and suggestions...
Regards,
Gonzal
 

View 9 Replies View Related

Schemas, Users, Logins, Database Roles, Application Roles

Mar 5, 2006

Hello,

I am new user of SQL Server. I have some problems with these words. I want to make my database works in my specified permissions. I will specify permissions with schemas and these schema wants an owner. I want this owner should be my user. When creating a user it needs a valid login. I am selecting my login and it occurs and error says this login has an different user. I am specifying permissions with roles. But i can't make association all of them. I hope i told my problem to you as well. If you explain these words to me and tell me how can i do my database's works with my own schemas, users and roles i'll be grateful. Thanks for advices.

Happy coding...

View 4 Replies View Related

Add User/Set Roles In Code And Read Roles

Jan 28, 2004

Can you write a stored procedure to add a user to your DB and set the roles the user belongs to?

I want to write a stored proc. to add users and set roles so it can be used in code instead of doing it manually.

After the user has been added and their roles set, can you write another stored proc. to give you what roles they belong to?

View 3 Replies View Related

SQL Server Roles && ASP.NET 2.0 Forms Authentication Roles

Jun 16, 2006

Apologies if my post does not fit into this forum. I initially tried the SQL Server Data Access forum but I now think my question is more security related.

Is it possible for a web user who has been successfully authenticated with forms authentication to be authorised to use a SQL Server 2000 role depending on a particular ASP.NET 2.0 role that they have been authorised to use? I understand that that I can assign a SQL Server 2000 role to the ASPNET or NETWORK SERVICE account but this will grant access to anonymous web users to the database role. I can ensure that I only call stored procedures which access sensitive data in web pages that are in restricted by ASP.NET roles. However, it would be nice to also restrict stored procedures via the ASP.NET 2.0 Forms Authentication roles.

If this is not possible have you got any bright ideas how I could restrict access to stored procedures who are anonymous web users.

Many thanks,

Mark

View 1 Replies View Related

SQL Server Roles, Windows Groups && ASP.NET Allow Roles

May 6, 2007

I'm developing an ASP.NET2.0 application which accesses a SQL Server 2005 Express database. I plan to use integrated security for access to the database.

I'm confused about the relationships between Windows groups, the ASP.NET web.config file <allow roles=.../> and SQL Server roles.

I would like to create a Windows group to which I can assign multiple users and grant that group access to a Web Site using windows authentication and also grant that windows group access to the database my web application uses.

I have gotten the combination of Windows Authentication to the web site and to the database to work for a specific windows user but I am having trouble determining the combination of database security entities I must create to allow access to my database by members of the windows group.

For a Windows user:

1. Create Windows user

In SQL Express

2. CREATE LOGIN FROM WINDOWS WITH DEFAULT_DATABASE =

3. CREATE USER FOR LOGIN

4. CREATE ROLE

5. EXEC sp_addrolemember <role-name> <user-name>



For a Windows group, what would be the equivalent commands necessary to grant a windows group access to my database? Specifying the Windows Group name in sp_addrolemember does not appear to be sufficient even though the documentation states that a windows group name is a valid value for the member name argument.






View 3 Replies View Related

Fixed Database Roles Vs Application Roles

Aug 24, 2006

After reading Books Online, I am still confused with Database Role vs Application role.

My intention is to control the end users' authority on the database, where the end users will access through Winforms client application. With proper assignment of schema and database roles to an user, I believe this will enough to control the permisison of an user.

If this is the case, why Application role exists? When and why should I use Application Role? How is it different from Fixed Database Role?

View 14 Replies View Related

Oracle Predefined Roles Vs Ms Sql Roles

May 3, 2005

Hi! Can anyone say which ms sql server predefined roles are similar to the following oracle predefined roles: dba, connect, resource. I already know that sysadmin in MS SQL Server is the same as DBA in Oracle but what about the rest?
Thanks a lot.

View 4 Replies View Related

How To Decide On Server Roles And DB Roles

Mar 2, 2006

I am in the process of locking down the SQL Server in an environment that is considered to be in production (pilot stages) and there is no staging or test environment that mirrors it. I need assistance in determining the server and database roles to assign to existing logins, most of which currently have sa and dbowner rights. Because it is not a development environment, I need to be sure that downgrading the server and/or database level permissions will not break any functionality.

I'm starting with the logins that have the SA fixed server role. These logins need to be able to install applications that require the use of a backend database, which will be stored on SQL Server. In addition, through the installation process a new login/password for the newly created database(s) is normally created. For the existing logins with the SA fixed server role, will downgrading to the securityadmin and dbcreator roles be sufficient to facilitate those needs, or are those too much/ too little? And should any user account ever be granted the SA role? If so, what questions could I ask to determine this need?

Since these install process for these applications usually prompt to install using SA or local system account to authenticate to SQL to create the new database(s), that account should have securityadmin and dbcreator roles to create the database and its tables, as well as add a new login to that database.

Please address this question, keeping in mind that the logins will only be performing the described actions, installing apps using SQL Server as the backend database and adding a login to that database (which may or may not be done during the installation process).

Thank you,
nu_dba

View 1 Replies View Related

Error With Membersip And Roles Cannot Resolve The Collation Conflict Between

May 21, 2007

I'm getting the following errors when trying to execute the following script on the server, its part of the standard asp.net membership and roles, anybody have any ideas how I get get round this?   Msg 468, Level 16, State 9, Procedure aspnet_UsersInRoles_RemoveUsersFromRoles, Line 50
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
Msg 468, Level 16, State 9, Procedure aspnet_UsersInRoles_RemoveUsersFromRoles, Line 58
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
Msg 468, Level 16, State 9, Procedure aspnet_UsersInRoles_RemoveUsersFromRoles, Line 84
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
Msg 468, Level 16, State 9, Procedure aspnet_UsersInRoles_RemoveUsersFromRoles, Line 92
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
  /****** Object: StoredProcedure [dbo].[aspnet_UsersInRoles_RemoveUsersFromRoles] Script Date: 05/20/2007 11:23:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_RemoveUsersFromRoles]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE [dbo].[aspnet_UsersInRoles_RemoveUsersFromRoles]
@ApplicationName nvarchar(256),
@UserNames nvarchar(4000),
@RoleNames nvarchar(4000)
AS
BEGIN
DECLARE @AppId uniqueidentifier
SELECT @AppId = NULL
SELECT @AppId = ApplicationId FROM aspnet_Applications WHERE LOWER(@ApplicationName) = LoweredApplicationName
IF (@AppId IS NULL)
RETURN(2)


DECLARE @TranStarted bit
SET @TranStarted = 0

IF( @@TRANCOUNT = 0 )
BEGIN
BEGIN TRANSACTION
SET @TranStarted = 1
END

DECLARE @tbNames table(Name nvarchar(256) NOT NULL PRIMARY KEY)
DECLARE @tbRoles table(RoleId uniqueidentifier NOT NULL PRIMARY KEY)
DECLARE @tbUsers table(UserId uniqueidentifier NOT NULL PRIMARY KEY)
DECLARE @Num int
DECLARE @Pos int
DECLARE @NextPos int
DECLARE @Name nvarchar(256)
DECLARE @CountAll int
DECLARE @CountU int
DECLARE @CountR int


SET @Num = 0
SET @Pos = 1
WHILE(@Pos <= LEN(@RoleNames))
BEGIN
SELECT @NextPos = CHARINDEX(N'','', @RoleNames, @Pos)
IF (@NextPos = 0 OR @NextPos IS NULL)
SELECT @NextPos = LEN(@RoleNames) + 1
SELECT @Name = RTRIM(LTRIM(SUBSTRING(@RoleNames, @Pos, @NextPos - @Pos)))
SELECT @Pos = @NextPos+1

INSERT INTO @tbNames VALUES (@Name)
SET @Num = @Num + 1
END

INSERT INTO @tbRoles
SELECT RoleId
FROM dbo.aspnet_Roles ar, @tbNames t
WHERE LOWER(t.Name) = ar.LoweredRoleName AND ar.ApplicationId = @AppId
SELECT @CountR = @@ROWCOUNT

IF (@CountR <> @Num)
BEGIN
SELECT TOP 1 N'''', Name
FROM @tbNames
WHERE LOWER(Name) NOT IN (SELECT ar.LoweredRoleName FROM dbo.aspnet_Roles ar, @tbRoles r WHERE r.RoleId = ar.RoleId)
IF( @TranStarted = 1 )
ROLLBACK TRANSACTION
RETURN(2)
END


DELETE FROM @tbNames WHERE 1=1
SET @Num = 0
SET @Pos = 1


WHILE(@Pos <= LEN(@UserNames))
BEGIN
SELECT @NextPos = CHARINDEX(N'','', @UserNames, @Pos)
IF (@NextPos = 0 OR @NextPos IS NULL)
SELECT @NextPos = LEN(@UserNames) + 1
SELECT @Name = RTRIM(LTRIM(SUBSTRING(@UserNames, @Pos, @NextPos - @Pos)))
SELECT @Pos = @NextPos+1

INSERT INTO @tbNames VALUES (@Name)
SET @Num = @Num + 1
END

INSERT INTO @tbUsers
SELECT UserId
FROM dbo.aspnet_Users ar, @tbNames t
WHERE LOWER(t.Name) = ar.LoweredUserName AND ar.ApplicationId = @AppId

SELECT @CountU = @@ROWCOUNT
IF (@CountU <> @Num)
BEGIN
SELECT TOP 1 Name, N''''
FROM @tbNames
WHERE LOWER(Name) NOT IN (SELECT au.LoweredUserName FROM dbo.aspnet_Users au, @tbUsers u WHERE u.UserId = au.UserId)

IF( @TranStarted = 1 )
ROLLBACK TRANSACTION
RETURN(1)
END

SELECT @CountAll = COUNT(*)
FROMdbo.aspnet_UsersInRoles ur, @tbUsers u, @tbRoles r
WHERE ur.UserId = u.UserId AND ur.RoleId = r.RoleId

IF (@CountAll <> @CountU * @CountR)
BEGIN
SELECT TOP 1 UserName, RoleName
FROM @tbUsers tu, @tbRoles tr, dbo.aspnet_Users u, dbo.aspnet_Roles r
WHERE u.UserId = tu.UserId AND r.RoleId = tr.RoleId AND
tu.UserId NOT IN (SELECT ur.UserId FROM dbo.aspnet_UsersInRoles ur WHERE ur.RoleId = tr.RoleId) AND
tr.RoleId NOT IN (SELECT ur.RoleId FROM dbo.aspnet_UsersInRoles ur WHERE ur.UserId = tu.UserId)
IF( @TranStarted = 1 )
ROLLBACK TRANSACTION
RETURN(3)
END

DELETE FROM dbo.aspnet_UsersInRoles
WHERE UserId IN (SELECT UserId FROM @tbUsers)
AND RoleId IN (SELECT RoleId FROM @tbRoles)
IF( @TranStarted = 1 )
COMMIT TRANSACTION
RETURN(0)
END
'
END
GOAny help appreciated thanks,   

View 5 Replies View Related

SQL 2005: Pooling, Application Roles And SQL Server Error 18059

Nov 24, 2007

Hi all:

[Posting this in the security forum because in this forum I found a related post.]

I have a problem with SQL Server 2005 and application roles and pooling. I needed to use application roles and I needed to use pooling at the same time for an application. I am using sp_setapprole and sp_unsetapprole. In order to ensure that the application role is always set and unset by the application, I actually developed a custom Data Provider based on the SqlClient Data Provider. I have a custom Connection and Command class that wrap the SqlClient versions. Upon opening my custom Connection class, I execute the sp_setapprole stored procedure. Upon closing or disposing the connection, I call sp_unsetapprole.

This works fine in 99% of my tests. However, I have three or four methods (always the same ones, but one only fails ever so often) that fail, but only under the following circumstances:


Pooling is turned on (but pool size doesn't matter)

I am using my custom Data Provider (using System.Data.SqlClient does not cause this issue... but I am also not using approles then)

When other tests have run in the same test run. I.e. when I run the failing methods by themselves in a test run, there is no problem.
So it seems to me that the problem is related to using application roles with pooling turned on. For scalability reasons, we cannot turn pooling off. When the methods fail, I see the following two (2) entries in the SQL Log:


Error: 18059, Severity: 20, State 1.

The connection has been dropped because the principal that opened it subsequently assumed a new security context, and then tried to reset the connection under its impersonated security context. This scenario is not supported. See "Impersonation Overview" in Books Online.
I understand the error message somewhat. However, I am not sure why the "reset" of the connection occurs. My code does not call reset anywhere, so it must be something that happens in the background.

I am reviewing code to see if there is possibly a situation where the sp_unsetapprole procedure does not get called or does not get called successfully, but there is a lot of code (in many custom components).

I would like to know if anyone has a suggestion on how to solve this problem, or, find the code that may be causing the problem.

Thanks in advance,

SA.

View 3 Replies View Related

Db Roles / Server Roles

Apr 15, 2007

Hi,

I'm looking for some guidance/help regarding setting up a sa - lite account in SQL 2005. I need to give another admin rights to create/monitor maintenance plans, backup and restore databases, monitor performance/logins, but NOT be able to have any rights on several tables (and of course not being able to set user permissions).

I've tried using server and db roles but haven't been able to determine how to give someone w/o full sa rights access to maintenance plans.

If you can think of soemthing, please let m eknow.

Jenn

View 4 Replies View Related

Assigning Roles To Roles

Mar 10, 2004

I have MS SQL Server 2000 DB.
I have created a User and created some tables for the same.
I created a Role named A and granted Select Permissions for few tables to that roles.

When I created another Role named B and added this role (A) to B, the permissions are not being xferred to B. Bcos of which, if i assign an User to Role B, he is not able to select the tables for which permissions have been given thru role A.

Note : If i give assign directly the user to Role A, it is working. But i want to assign User to role A only thru B.

View 1 Replies View Related

Inserting Into A SQL Error

Feb 25, 2006

hey guys I got an error when trying to insert an SQL statement.
basically it when I try to insert into a unique ID column I think
error is:
Compiler Error Message: BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.Source Error:





Line 51: objCmd = New SQLCommand(strSQL1, SqlConn)
Line 52:
Line 53: objCmd.Parameters.Add(New SqlParameter("@CustomerID"))
Line 54: objCmd.Parameters("@CustomerID").Value = UserID
Line 55: objCmd.Parameters.Add(New SqlParameter("@CompanyID", _Source File: C:Prototypeofficial1html icketsystem.aspx    Line: 53
 

Dim strConnection as string = ConfigurationManager.ConnectionStrings("GeolinkSupportdb").connectionstring
Dim sqlConn = New SqlConnection(strConnection)
dim mu = Membership.GetUser()
dim UserID = mu.ProviderUserKey.ToString()

Sub Page_Load(sender as Object, e as EventArgs)

If Not IsPostBack() then
'1. Create a connection
Dim sqlConn = New SqlConnection(strConnection)
'2. Create the command object, passing in the SQL string
Const strSQL as String = "SELECT IssueID, IssueName FROM Support_Issue;"
sqlConn.Open()
Dim myCommand as New SqlCommand(strSQL, sqlConn)
'3. Create the DataReader

Dim objDR as SqlDataReader
objDR = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

'Databind the DataReader to the listbox Web control
TicketIssue.DataSource = objDR
TicketIssue.DataTextField = "IssueName"
TicketIssue.DataValueField = "IssueID"
TicketIssue.DataBind()

'Add a new listitem to the beginning of the listitemcollection
TicketIssue.Items.Insert(0, new ListItem("-- Choose an Issue --"))
objDR.close()
sqlConn.Close()

'assign fullname from profile and company ID to the text fields.
FullName.Text = profile.firstName & " " & profile.lastName
Company.Text = profile.CompanyID
end if
End Sub
Sub Submit(sender as Object, e as EventArgs)
Dim rightNow as DateTime = DateTime.Now
Dim strSQL1 = "insert into Support_Ticket (CustomerID, CompanyID, Subject, Problem, Open_Date, IsClosed) Values (@CustomerID, @CompanyID, @Subject, @Problem, @OpenDate, @IsClosed);"
Dim objCmd As SqlCommand
objCmd = New SQLCommand(strSQL1, SqlConn)

objCmd.Parameters.Add(New SqlParameter("@CustomerID", _
SqlDbType.uniqueidentifier))
objCmd.Parameters("@CustomerID").Value = UserID
objCmd.Parameters.Add(New SqlParameter("@CompanyID", _
SqlDbType.uniqueidentifier))
objCmd.Parameters("@CompanyID").Value = profile.CompanyID
objCmd.Parameters.Add(New SqlParameter("@Subject", _
SqlDbType.varchar, 50))
objCmd.Parameters("@Subject").Value = Subject.Text
objCmd.Parameters.Add(New SqlParameter("@Problem", _
SqlDbType.ntext))
objCmd.Parameters("@Problem").Value = TicketInfo.Value
objCmd.Parameters.Add(New SqlParameter("@Open_Date", _
SqlDbType.DateTime))
objCmd.Parameters("@Open_Date").Value = rightNow.ToString("dd/MM/yyyy , HH:mm:ss")
objCmd.Connection.Open()
objCmd.Parameters.Add(New SqlParameter("@IsClosed", _
SqlDbType.bit))
objCmd.Parameters("@IsClosed").Value = 0
' Test whether the new row can be added and display the
' appropriate message box to the user.
Try
Catch ex As SqlException
objCmd.ExecuteNonQuery()
Message.InnerHtml = "<b>Record Added</b> to Database<br>"

If ex.Number = 2627 Then
Message.InnerHtml = "ERROR: A record already exists with " _
& "the same primary key"
Else

Message.InnerHtml = "ERROR: Could not add record, please " _
& "ensure the fields are correctly filled out"
Message.Style("color") = "red"

End If
End Try
objCmd.Connection.Close()
end sub
 
the database looks like this
TicketID             uniqueidentifier      CustomerID        uniqueidentifier       Subject               varchar(50)               Problem              ntext                          Open_Date        datetime                    IsClosed             bit                              Closed_Date      datetime                   DeptID               uniqueidentifier     CompanyID       varchar(50)            

View 2 Replies View Related

Error While Inserting!!!!

Apr 20, 2004

Hey folks,
I am trying to updat a table by inserting values from another table into the parent table. The SQL being used is:
"insert into "LogSchema"."_rt1182" select * from "LogSchema"."_rt557" where recordID not in (select * from "LogSchema"."_rt1182") ORDER BY TIMESTAMP"
I have used the above statement and was successful, but with these two particluar tables I am getting an error message" Wrong number of values to INSERT"
Please lemme know, what this means and how to correct this problem!
TIA

View 3 Replies View Related

Sql 6.5 Error 605 When Inserting Data

May 8, 2000

i get error 605 on several occassions... namely when i am doing a bcp into the database OR when a user is trying to update a record. it seems very sparodic otherwise, but it always happens during the bcp insert. if anyone has any ideas or suggestions on how to correct this issue, it would be greatly appreciated. need additional info?

View 5 Replies View Related

Error Inserting Into Table &#34;&#34;

Mar 25, 1999

We are running a application that uses SQL. No users use this database but the application. We have been getting an error stating that there was an error inserting into one of my tables. We have increased the LE Threshold to 10000 and have also increased my locks to 200000 but it still doesn't get rid of the problem. Any ideas as to why. I can't imagine that this application will hold that many locks but then again I'm not the developer. Any suggestions will help.

Ben

View 2 Replies View Related

Error While Inserting To Table

Mar 29, 2007

Hi all,
I made a C# function to insert new row to MS SQL Server 2005. However, I kept getting this error when I executed it:


Code:


Line 1: Incorrect syntax near '0'.
Unclosed quotation mark before the character string '','{ 0 }','Sun, Mar 25, 2007 04:33:00 PM')'.



here is the sql insert statement


Code:


insert into Temip_tmp_3(Managed_object, Alarm_type, Perceived_Severity, Probable_Cause, Domain, Additional_Text, Specific_Problems, Original_Event_Time ) values ('','EquipmentAlarm','Major','EquipmentMalfunction','Domain tsel_ns:.dom.radio_ericsson','"EXTERNAL ALARM RECEIVER FAULT *** ALARM 121 A2/IO_DEV BTAK1 042/0700H U 070325 1633 EXTERNAL ALARM RECEIVER FAULT AP APNAME NODE NODENAME 1 AP_BTAK1_C A AP_BTAK1_A APNODE FCODE B FAULT CODE 23 **SpecificProblem:121 , AdditionalInfo:@@"','{ 0 }','Sun, Mar 25, 2007 04:33:00 PM')



I believe there is not a single quotation mark unclosed in my query. And, what's so funny is when I tried to execute the query on SQL Server Enterprise Manager, it worked.
I don't know, maybe I missed something.
Can you guys please help me figure this out?

Thank you very much in advance.

Shinta

View 1 Replies View Related

Getting Error When Inserting Data

May 14, 2014

i have created a multiple database for other reasons i have to change all into one data base for that i have done graphically by using generate scripts by using this all data base tables, & store procedures all are created . by using webform i just inserting data to database. but here i am getting an error to me that the error has "Cannot insert the values NULL Into column Tblename database.dbo.columnname does not allow nulls.insert fails the statement has been terminated."here the primary key has not working in runtime.

View 1 Replies View Related

Error While Inserting Time

Feb 10, 2007

hi i am trying to insert time in my column which is in my table.my table has one column named as "intime" which has datatype as datetime.

i am doing thuis in vb.net.
i used this code in vb.net to get time:

dim dat as datetime=datetime.now.tostring("hh:mm:ss tt")
and i got time.but i am having this spc for insert:

create procedure sptimeinsert(@time datetime)
as

insert into time values:

An unhandled exception of type 'System.Data.SqlTypes.SqlTypeException' occurred in system.data.dll

Additional information: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM

please any one help to solve this error.

View 5 Replies View Related

Error While Inserting Data In DataBase ?

Oct 15, 2006

my requirment is insert TableName and JourneyDate and FlightNumber alongwith otherdata at RunTime but i get error, I tried it several times. Table Structure is:  Create Table HA142
(
JourneyDate DateTime primary key,
FlightNo char(5)not null FOREIGN kEY REFERENCES FLIGHTS(FlightNo),
FirstClassSeatAvalable int,
BusinessClassSeatAvalable int,
EconomyClassSeatAvalable int,
FsWaitingAvalable int,
BsWaitingAvalable int,
EcWaitingAvalable int
)  string flightno = drpFlightNo.SelectedItem.Text;
string JourneyDate = Session["JourneyDate"].ToString();
string newStrign = ",18,42,280,3,7,35)";
SqlConnection myConn = new SqlConnection("workstation id=JASIM;packet size=4096;user id=ASPNET;data source=JASIM;persist security info=False;initial catalog=Test");
SqlCommand populateFlightTable = new SqlCommand("INSERT INTO "+flightno+" VALUES("+JourneyDate+","+flightno+newStrign,myConn);
myConn.Open();
populateFlightTable.ExecuteNonQuery();
myConn.Close(); whenever compiler reached to populateFlightTable.ExecuteNonQuery(); I received error. i tried it to rectify several times but no result.plz hemp me...

View 3 Replies View Related

Inserting More Then 999.99 In Money Field Error

Feb 21, 2007

I am trying to insert 1000000.00 into my sql table from a webpage.  I as long as the amount is 999.99 or less it works fine, once higher then that amount it gives me an error.
 Below is the code I am using to do the insert, it gets the error on the insert and the update both:
 I am getting the error on the price inserting the FormatCurrency(txtprice.Text)
SelectStatement = "Insert crewchief (crewchief, price, car_num) Select '" & txtcrewchief.Text & "', " & FormatCurrency(txtprice.Text) & ", '" & txtcarnum.Text & "'"
Adapter.SelectCommand = New SqlClient.SqlCommand(SelectStatement, myConnection)
MyCommandBuilder = New SqlClient.SqlCommandBuilder(Adapter)
Adapter.Fill(MatcherDS, "temp")
Any ideas on why?
 
Thank you

View 2 Replies View Related

SqlDataSource Inserting Event Error

Apr 12, 2007

Greetings,
When using Inserting event of SqlDataSource ASP.NET gives me an error when I reference InsertParameter by Name
An SqlParameter with ParameterName 'CreatedByEmployeeId' is not contained by this SqlParameterCollection.
However, when I reference parameter by index everything works.
Is this a bug or I'm doing something wrong?
Here's the code:
<asp:SqlDataSource ID="dsRole" runat="server" ConnectionString="<%$ ConnectionStrings:SecurityConnectionString %>" DeleteCommand="spDeleteRole" InsertCommand="spAddRole" SelectCommand="spGetRole" UpdateCommand="spUpdateRole" DeleteCommandType="StoredProcedure" InsertCommandType="StoredProcedure" SelectCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="UpdatedByEmployeeId" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="CreatedByEmployeeId" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="RoleId" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
When using parameter name, I get an error:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters("CreatedByEmployeeId").Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub
When using index instead of name, there's no problem:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters(2).Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub

View 2 Replies View Related

Error When Inserting To Aspnet_Roles Table

Jun 21, 2007

hi,
 I am using asp.net web admin tool to create users and the other personal details of the user are stored in a table called "Users". So in my Users table I have a field called "Id" which is of datatype UniqueIdentifier. The UserId generated in the aspnet_Membership table is also stored in my "Users" table's Id field. The problem is that an error is thrown when executing the statement
System.Web.Security.Roles.AddUserToRole(name, Role). The parameters name and role are getting values correctly. But as soon as this is executed a sql exception is thrown saying that  "The conflict of interleave for the equal operator cannot be solved to." 
 Am not able to solve this.Pls help me out.
Thanks in Advance.
 
 

View 3 Replies View Related

Error Inserting Data In ASPNETDB.net

May 9, 2008

I created my own table on the ASPNETDB.mdf file.
When i try to insert data on it, i get an exception:
System.Data.SqlClient.SqlException was unhandled by user code  Message="String or binary data would be truncated.
The statement has been terminated."  Source=".Net SqlClient Data Provider"  ErrorCode=-2146232060  Class=16  LineNumber=1  Number=8152  Procedure=""  Server="\\.\pipe\33189AFE-4730-4B\tsql\query"....
My C# code to insert:SqlConnection conexao =
new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
string query = "Insert Into NovasMaquinas " +"(NomeDaMaquina, FicheiroExecutavel, FicheiroXML, AdminQueSubmeteu, Autor, VmID)" +
"Values (@NomeDaMaquina, @FicheiroExecutavel, @FicheiroXML, @AdminQueSubmeteu, @Autor, @VmID)";SqlCommand cmd = new SqlCommand(query, conexao);
cmd.Parameters.AddWithValue("@NomeDaMaquina", textboxNomeVM.Text);cmd.Parameters.AddWithValue("@FicheiroExecutavel", path + fileUploadEXE.PostedFile.FileName);
cmd.Parameters.AddWithValue("@FicheiroXML", path + fileUploadEXE.PostedFile.FileName);cmd.Parameters.AddWithValue("@AdminQueSubmeteu", User.Identity.Name);
cmd.Parameters.AddWithValue("@Autor", textboxAutorVM.Text);cmd.Parameters.AddWithValue("@VmID", Guid.NewGuid().ToString());
conexao.Open();
//cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();    //THAT IS THE LINE WHERE THE EXCEPTION IS THROWN
conexao.Close();
 
Any ideas wath i'm doing wrong?
 

View 2 Replies View Related

Syntax Error With Inserting To Database

Jul 11, 2006

I'm getting a syntax error in my insert data:

Error Executing Database Query.

Syntax error in INSERT INTO statement.

The error occurred in D:HostingkpstoolinsertPage.cfm: line 132
130 : datasource= "kpstool_accesscf_jobs">
131 : INSERT INTO Jobs (Position, Needs, Necessary)
132 : VALUES ('#form.Position#','#form.Needs#','#form.Necessary#')
133 : </cfquery>
134 : <cfoutput>

This is the code for the form that this code is referring to:
<form action="insertpage.cfm" method="post" name="Form" id="Form">
Position:
<input type="text" name="Position" size="25" maxlength="25">
<br>
<input type="hidden" name="Position_required" value="You must enter position">
<br>
Needs:
<input type="text" name="Needs" size="25" maxlength="25">
<br>
Necessary:

<input type="text" name="Necessary" size="25" maxlength="25">
<br>
</p>
<p>
<input type="submit" name="Submit" value="insert data">
<input type="Reset" name="submit" value="Clear form">
<br>
</p>
</form>

Any help would be great.

View 7 Replies View Related

Inserting Data - Foreign Key Error

Feb 17, 2006

How do I go about inserting records on a table that has a PK/FK relationship with another table?? I get a foreign key error everytime I try :)

View 1 Replies View Related

Out Of Memory Error Inserting Files

Oct 4, 2007

Hello.
I'm working with SQL Server 2005 Standard edition.
I have a Java program that loads PDF files into the database. I have a table called T08_entity which, among others, has two IMAGE columns. The first Image column is for the original PDF file. The second one is for the PDF file with modified permissions (printing, saving, etc). This is made using the i-text library.
The programs looks for the content of a disk folder, reads the contents of the folder, and inserts, one by one, the pdf files (besides other fields, like the name of the file, and ID, etc... but these are varchar or int fields. No problem with these.
When the folder has only small files (smaller that 7-8 mb), it loads them without any problem into the database. But when the folder has bigger files (>10mb, more or less...) I get an OUT OF MEMORY error.
I'm using the latest sqljdbc.jar driver (v1.2.2727). My server computer has only 1GB of RAM... but I've read that this latest driver can load big amounts of binary data using the connection property "responseBuffering=adaptive".
Here is a sample of my code (at least the most relevant lines):


This is my connection code:



public String getConnectionUrl(){
return "jdbc:sqlserver://"+serverName+":"+portNumber+";databaseName="
+databaseName+";responseBuffering=adaptive;selectMethod=cursor";
}

public java.sql.Connection getConnection(){
try{

...

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password); if (con.getAutoCommit())
{
con.setAutoCommit(false);
}
...
}
catch(Exception e){
System.out.println("etc, etc...");
}
return con;
}




The following is a loop where each loop represents a file in the folder:




File[] contenido = archivo.listFiles();
for(int i=0;i<contenido.length;i++)
{
if (contenido[i].isDirectory())
{
procesarDirectory(contenido[i]);
}else
{
insertDirectory(contenido[i]);
}
}



...And this is the insertDirectory procedure which inserts every file: the pdffile and pdffilenoperm are the IMAGE columns. The rest are varchar or int columns:






public void insertDirectorio(File archivo) {...if (archivo.isFile()){ pstmt =con.prepareStatement("INSERT INTO temp_carga "+ "(directory, name, dir_sup, filetype, pfilesize,pdffile,pdffilenoperm)"+ " values (?,?,?,?,?,?,?)"); }...
long tamano = archivo.length();

pstmt.setString(1,pdffile.getPath());
pstmt.setString(2,pdffile.getName());
pstmt.setString(3,pdffile.getParent());

pstmt.setString(4,filetype);

if (pfilesize != 0) {
pstmt.setLong(5,pfilesize);
}
else
{
pstmt.setString(5,null);
}

if (pdffile.isFile()) {
try{

//INSERTS ORIGINAL FILE................
int fileLength = Integer.MIN_VALUE;
is = new FileInputStream(pdffile);
fileLength= (int) pdffile.length();
pstmt.setBinaryStream(6, is, fileLength);


//INSERTS FILE WITHOUT PERMISSIONS
(THIS PART OF THE CODE IS LONG AND IRRELEVANT, IT JUST USES THE ITEXT LIBRARY TO MODIFY THE PDF FILE. AT THE END, I HAVE THE FILE IN AN OUTPUT STREAM, AS SHOWN HERE:)
ByteArrayInputStream inputnoimp = new ByteArrayInputStream(outnoimp.toByteArray());
pstmt.setBinaryStream(7,inputnoimp,(int)outnoimp.size());
} catch(Exception e) {
err = e.toString();
}
}
pstmt.executeUpdate();
con.commit();
pstmt.close();
this.closeConnection();
}catch(java.sql.SQLException e) {
err = e.toString();
}
}




Well, as I said, when I run the program, when it reads smaller files, there's no problem. But when it gets a big file, I get the OUT OF MEMORY error. I have another application that reads pdf files ONE AT A TIME, using a code very much like this one, and it reads big files (>30mb) with no problems. The problems is with this one.
Any help will be appreciated. If you have any question to clarify the problem, just tell me.
Thanks in advance.
Eric.

View 7 Replies View Related

Error With Names Like Georgia's Way While Inserting Into A Database

May 14, 2008

Hello All,i am trying to insert some values into a table in sql database. i keep getting error saying incorrect syntax near 'S'. i fired up my debugger and found that one of the row contains name like Georgia's way. i am getting error at the "S" in georgia's way. how can i fix that. here is my code for inserting the values in to the table SqlConnection mysqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["ImportexcelConnectionString"].ConnectionString); mysqlcon.Open(); foreach (DataRow dr1 in objDataSet.Tables[0].Rows) { String sqlinsert = String.Format("insert into Det values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7},{8},'{9}','{10}','{11}','{12}')"
, dr1[0].ToString()
, dr1[1].ToString()
, dr1[2].ToString()
, dr1[3].ToString() -- this is the column where georgia's way is
, dr1[4].ToString()
, dr1[5].ToString()
, dr1[6].ToString()
, Convert.ToDecimal(dr1[7].ToString())
, Convert.ToDecimal(dr1[8].ToString())
, dr1[9].ToString()
, dr1[10].ToString()
, dr1[11].ToString()
, dr1[12].ToString());

new SqlCommand(sqlinsert, mysqlcon).ExecuteNonQuery(); LabelImport.Text = " Row Inserted"; } mysqlcon.Close();  can some please help me out.Thanks a lot 

View 16 Replies View Related

Datetime Error Inserting Inql Server Plz Help

May 28, 2008

i use this statement to insert into sql tablecmdInsert = New SqlCommand("insert into empbill ([deptcode],[personNo,[entrydate]] ) values(" & Val(eno.Text) & "," & Val(TextBox5.Text) & ", " & dd.Text  & "')", db)
cmdInsert.ExecuteNonQuery()
dd.Text   value is 22/5/2008  it come from datetime calender
the  entrydate field datatype is datetime
i found data always 1/1/1900 00:00:00
how i enter my date

View 10 Replies View Related

Error Inserting To Database: Parameterized Query

Jun 11, 2008

Hi, Im struggling with this insert statement, I want to use with a AJAX validation Post Form page.
Its quite straght forward, if a search query returns null the insert these values. The search query does work, what I mean by that is that txt field values seem to pass for search but not insert. Any help out there cheers Paul if (RowCount == 0)
{String strSQL = "INSERT INTO Mail_List (FirstName, Email) VALUES( @FirstName, @Email )";
 
try
{mySqlConn = new SqlConnection(strSqlConn);
mySqlConn.Open();SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand(strSQL, mySqlConn);cmd.Parameters.AddWithValue("@FirstName", Request.Form["FirstName"]);cmd.Parameters.AddWithValue("@Email", Request.Form["Email"]);
cmd.ExecuteNonQuery();
lblStatus.Text = "Registration Successful";
}

View 2 Replies View Related

Inserting Of Duplicate Records Error Message

Jan 15, 2004

I would like to know what options I have with regards to trapping a duplicate record
before it tries to post to a SQL database. I have set the column to unique in SQL. But
when I try to use ASP and post a duplicate record I get a system error. I would like to
just create a referential error to notify the user that they cannot post a duplicate record
please try again. Any help would be greatly appreciated.

RT

View 1 Replies View Related

INSTEAD OF Trigger - Error Inserting Into NOT NULL Field

Oct 7, 2004

I've just noticed some strange behavior that seems like a bug to me.
It's much easier to follow an example of it that to outright explain it, so here goes.

I have a table defined with a NOT NULL constraint on a column and a default clause:
-- DROP TABLE TestTable
CREATE TABLE TestTable ( TestField0 varchar(10), TestField1 varchar(10) NOT NULL DEFAULT ('a') )

I have a view defined on the table, in this example case, the view just mirrors the table one to one:
-- DROP VIEW TestView
CREATE VIEW TestView as SELECT TestField0, TestField1 FROM TestTable

So far so good, if I run this statement, it works as I would expect and inserts the value and the default goes into the other field:
INSERT INTO TestView (TestField0) SELECT 'test'

Now... If I add an INSTEAD OF trigger to the view, and have it perform the insert for me, I get an error with the same insert stmt:
-- DROP TRIGGER TestTrigger
CREATE TRIGGER TestTrigger ON TestView
INSTEAD OF INSERT AS
BEGIN
INSERT INTO TestTable (TestField0, TestField1)
SELECT TestField0, COALESCE(TestField1, 'X')
FROM inserted
END

Notice the trigger will ensure that a null value cannot be inserted into TestField1. If I run this insert stmt though I get an error:
INSERT INTO TestView (TestField0) SELECT 'test'

Server: Msg 233, Level 16, State 2, Line 1
The column 'TestField1' in table 'TestView' cannot be null.


Am I missing something or is this a bug?
Thanks

View 1 Replies View Related







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