Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Friday, March 30, 2012

Problem with calling methods of User Defined Types (udt)

Hello all,

I have scoured the internet looking for the answer to this question, but have come up blank, so I am making my very first post to a help site. Any ideas or solutions would be greatly appreciated.

I am running through some Samples in Sql Server 2005, and I am currently on the part about User Defined Types. I am running the "User-Defined Data Type (UDT) Sample" from this page: http://msdn2.microsoft.com/en-us/library/ms160738.aspx

So I'm using this code for a ComplexNumber type. The code works fine... mostly. I've compiled it and successfully loaded it into Sql Server 2005 (local instance). I can call all the functions like ToString() and what-not, but the problem comes when I try to call the CompareTo() function. If I pass in something other than a ComplexNumber type (such as a string), then the method correctly returns a -1. When I pass in a ComplexNumber type, I get the following error from the query window:

"Operand type clash: ComplexNumber is incompatible with sql_variant"

I am not declaring the variables as type sql_variant. Also, I have tried creating the second ComplexNumber type (that I am comparing it to) right inside the method call, as below:

DECLARE @.c ComplexNumber;
DECLARE @.c2 ComplexNumber;
DECLARE @.myInt int;
DECLARE @.vari sql_variant;
SET @.c = ComplexNumber::Parse('(1, 2i)');
SET @.c2 = ComplexNumber::Parse('(1, 3i)');

All of the following lines get the same error code:
SET myInt = @.c.CompareTo(@.C2);
SET myInt = @.c.CompareTo(ComplexNumber::Parse('(1, 3i)'));
@.vari = @.c;

That last one I just threw in there because I knew it had the same error code. Does anyone know why this is happening and what I can do to fix it? Even hints would be appreciated at this point (although solutions score bigger points!)

Banging my head against my cubicle,
Tim

I am not an expert, but I asked some, and the reply I got was:

"If he's implemented IComparable, the typical signature for CompareTo is:

public int CompareTo(object obj)

.NET object is treated as SQL_VARIANT, however, UDTs aren't compatiable with
SQL_VARIANT.

A better way to write the interface *should be*:

public int CompareTo(ComplexNumber obj)

This violates the IComparable interface, however: it requires object.

Since SQL Server doesn't use ICompareable for indexing, order by, group by,
implementing it is more or less useless. If I need to compare two instances,
I think its better to create a strongly-typed static method on the class
that does exactly that, returning SqlInt16 instead of int.

However, if you need IComparable for other reasons, then you have to live
with wart."

Does this help?

|||Wow, thanks man. All the examples I looked at (from Microsoft, no less) had implemented the IComparable. I had tried overloading the method before,only to find out that SQL Server doesn't support overloaded methods in UDTs. Anyways, since IComparable is useless, I took it out and it worked like a charm.

Thanks again!
Tim|||

I have a problem looks similar but it is little bit different. you are right that sqlserver is not using ICompareable.

but I using Data gridview Control with User defined Types. Problem is while doing sorting on this column it gives exception that Icomparable requires to be implemented. though i have implemented that Interface. but as SQL server is not using that method then who creates that exception. this is not problem with any other column of Datagridview. and i have created that User defined type with native serialization and also made IsByteOrdered to true.

Assembly is sucessfully deployed and i am able to insert and select data in datagridview. only problem while pressing column header of UDT column.

it seems that exception is thrown by sqlserver while comparision. here is the stack trace for exception.

" at System.Data.Common.SqlUdtStorage.CompareValueTo(Int32 recordNo1, Object value)\r\n at System.Data.Common.SqlUdtStorage.Compare(Int32 recordNo1, Int32 recordNo2)\r\n at System.Data.Index.CompareRecords(Int32 record1, Int32 record2)\r\n at System.Data.Index.IndexTree.CompareNode(Int32 record1, Int32 record2)\r\n at System.Data.RBTree`1.RBInsert(Int32 root_id, Int32 x_id, Int32 position)\r\n at System.Data.RBTree`1.Insert(K item)\r\n at System.Data.Index.InitRecords(IFilter filter)\r\n at System.Data.Index..ctor(DataTable table, Int32[] ndexDesc, IndexField[] indexFields, DataViewRowState recordStates, IFilter rowFilter)\r\n at System.Data.DataTable.GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)\r\n at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent)\r\n at System.Data.DataView.UpdateIndex(Boolean force)\r\n at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter, Boolean fireEvent)\r\n at System.Data.DataView.SetIndex(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter)\r\n at System.Data.DataView.set_Sort(String value)\r\n at System.Data.DataView.System.ComponentModel.IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.DataGridViewDataConnection.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.SortInternal(IComparer comparer, DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e)\r\n at System.Windows.Forms.DataGridView.OnMouseClick(MouseEventArgs e)\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.DataGridView.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at testAlarmType.Program.Main() in c:\\Manoj\\CSharp\\Work\\testAlarmType\\testAlarmType\\Program.cs:line 17\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"

let me know if any one has any workaround.

Thanks in advance.

|||I have tried to look at this, and while it seems that IComparable is not used by SQL Server 2005 it is used when ordering DataTables, which seems to be an oversight when the requirements for UDTs were written. I write more in this thread.

Problem with calling methods of User Defined Types (udt)

Hello all,

I have scoured the internet looking for the answer to this question, but have come up blank, so I am making my very first post to a help site. Any ideas or solutions would be greatly appreciated.

I am running through some Samples in Sql Server 2005, and I am currently on the part about User Defined Types. I am running the "User-Defined Data Type (UDT) Sample" from this page: http://msdn2.microsoft.com/en-us/library/ms160738.aspx

So I'm using this code for a ComplexNumber type. The code works fine... mostly. I've compiled it and successfully loaded it into Sql Server 2005 (local instance). I can call all the functions like ToString() and what-not, but the problem comes when I try to call the CompareTo() function. If I pass in something other than a ComplexNumber type (such as a string), then the method correctly returns a -1. When I pass in a ComplexNumber type, I get the following error from the query window:

"Operand type clash: ComplexNumber is incompatible with sql_variant"

I am not declaring the variables as type sql_variant. Also, I have tried creating the second ComplexNumber type (that I am comparing it to) right inside the method call, as below:

DECLARE @.c ComplexNumber;
DECLARE @.c2 ComplexNumber;
DECLARE @.myInt int;
DECLARE @.vari sql_variant;
SET @.c = ComplexNumber::Parse('(1, 2i)');
SET @.c2 = ComplexNumber::Parse('(1, 3i)');

All of the following lines get the same error code:
SET myInt = @.c.CompareTo(@.C2);
SET myInt = @.c.CompareTo(ComplexNumber::Parse('(1, 3i)'));
@.vari = @.c;

That last one I just threw in there because I knew it had the same error code. Does anyone know why this is happening and what I can do to fix it? Even hints would be appreciated at this point (although solutions score bigger points!)

Banging my head against my cubicle,
Tim

I am not an expert, but I asked some, and the reply I got was:

"If he's implemented IComparable, the typical signature for CompareTo is:

public int CompareTo(object obj)

.NET object is treated as SQL_VARIANT, however, UDTs aren't compatiable with
SQL_VARIANT.

A better way to write the interface *should be*:

public int CompareTo(ComplexNumber obj)

This violates the IComparable interface, however: it requires object.

Since SQL Server doesn't use ICompareable for indexing, order by, group by,
implementing it is more or less useless. If I need to compare two instances,
I think its better to create a strongly-typed static method on the class
that does exactly that, returning SqlInt16 instead of int.

However, if you need IComparable for other reasons, then you have to live
with wart."

Does this help?

|||Wow, thanks man. All the examples I looked at (from Microsoft, no less) had implemented the IComparable. I had tried overloading the method before,only to find out that SQL Server doesn't support overloaded methods in UDTs. Anyways, since IComparable is useless, I took it out and it worked like a charm.

Thanks again!
Tim
|||

I have a problem looks similar but it is little bit different. you are right that sqlserver is not using ICompareable.

but I using Data gridview Control with User defined Types. Problem is while doing sorting on this column it gives exception that Icomparable requires to be implemented. though i have implemented that Interface. but as SQL server is not using that method then who creates that exception. this is not problem with any other column of Datagridview. and i have created that User defined type with native serialization and also made IsByteOrdered to true.

Assembly is sucessfully deployed and i am able to insert and select data in datagridview. only problem while pressing column header of UDT column.

it seems that exception is thrown by sqlserver while comparision. here is the stack trace for exception.

" at System.Data.Common.SqlUdtStorage.CompareValueTo(Int32 recordNo1, Object value)\r\n at System.Data.Common.SqlUdtStorage.Compare(Int32 recordNo1, Int32 recordNo2)\r\n at System.Data.Index.CompareRecords(Int32 record1, Int32 record2)\r\n at System.Data.Index.IndexTree.CompareNode(Int32 record1, Int32 record2)\r\n at System.Data.RBTree`1.RBInsert(Int32 root_id, Int32 x_id, Int32 position)\r\n at System.Data.RBTree`1.Insert(K item)\r\n at System.Data.Index.InitRecords(IFilter filter)\r\n at System.Data.Index..ctor(DataTable table, Int32[] ndexDesc, IndexField[] indexFields, DataViewRowState recordStates, IFilter rowFilter)\r\n at System.Data.DataTable.GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)\r\n at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent)\r\n at System.Data.DataView.UpdateIndex(Boolean force)\r\n at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter, Boolean fireEvent)\r\n at System.Data.DataView.SetIndex(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter)\r\n at System.Data.DataView.set_Sort(String value)\r\n at System.Data.DataView.System.ComponentModel.IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.DataGridViewDataConnection.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.SortInternal(IComparer comparer, DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e)\r\n at System.Windows.Forms.DataGridView.OnMouseClick(MouseEventArgs e)\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.DataGridView.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at testAlarmType.Program.Main() in c:\\Manoj\\CSharp\\Work\\testAlarmType\\testAlarmType\\Program.cs:line 17\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"

let me know if any one has any workaround.

Thanks in advance.

|||I have tried to look at this, and while it seems that IComparable is not used by SQL Server 2005 it is used when ordering DataTables, which seems to be an oversight when the requirements for UDTs were written. I write more in this thread.

Problem with calling methods of User Defined Types (udt)

Hello all,

I have scoured the internet looking for the answer to this question, but have come up blank, so I am making my very first post to a help site. Any ideas or solutions would be greatly appreciated.

I am running through some Samples in Sql Server 2005, and I am currently on the part about User Defined Types. I am running the "User-Defined Data Type (UDT) Sample" from this page: http://msdn2.microsoft.com/en-us/library/ms160738.aspx

So I'm using this code for a ComplexNumber type. The code works fine... mostly. I've compiled it and successfully loaded it into Sql Server 2005 (local instance). I can call all the functions like ToString() and what-not, but the problem comes when I try to call the CompareTo() function. If I pass in something other than a ComplexNumber type (such as a string), then the method correctly returns a -1. When I pass in a ComplexNumber type, I get the following error from the query window:

"Operand type clash: ComplexNumber is incompatible with sql_variant"

I am not declaring the variables as type sql_variant. Also, I have tried creating the second ComplexNumber type (that I am comparing it to) right inside the method call, as below:

DECLARE @.c ComplexNumber;
DECLARE @.c2 ComplexNumber;
DECLARE @.myInt int;
DECLARE @.vari sql_variant;
SET @.c = ComplexNumber::Parse('(1, 2i)');
SET @.c2 = ComplexNumber::Parse('(1, 3i)');

All of the following lines get the same error code:
SET myInt = @.c.CompareTo(@.C2);
SET myInt = @.c.CompareTo(ComplexNumber::Parse('(1, 3i)'));
@.vari = @.c;

That last one I just threw in there because I knew it had the same error code. Does anyone know why this is happening and what I can do to fix it? Even hints would be appreciated at this point (although solutions score bigger points!)

Banging my head against my cubicle,
Tim

I am not an expert, but I asked some, and the reply I got was:

"If he's implemented IComparable, the typical signature for CompareTo is:

public int CompareTo(object obj)

.NET object is treated as SQL_VARIANT, however, UDTs aren't compatiable with
SQL_VARIANT.

A better way to write the interface *should be*:

public int CompareTo(ComplexNumber obj)

This violates the IComparable interface, however: it requires object.

Since SQL Server doesn't use ICompareable for indexing, order by, group by,
implementing it is more or less useless. If I need to compare two instances,
I think its better to create a strongly-typed static method on the class
that does exactly that, returning SqlInt16 instead of int.

However, if you need IComparable for other reasons, then you have to live
with wart."

Does this help?

|||Wow, thanks man. All the examples I looked at (from Microsoft, no less) had implemented the IComparable. I had tried overloading the method before,only to find out that SQL Server doesn't support overloaded methods in UDTs. Anyways, since IComparable is useless, I took it out and it worked like a charm.

Thanks again!
Tim|||

I have a problem looks similar but it is little bit different. you are right that sqlserver is not using ICompareable.

but I using Data gridview Control with User defined Types. Problem is while doing sorting on this column it gives exception that Icomparable requires to be implemented. though i have implemented that Interface. but as SQL server is not using that method then who creates that exception. this is not problem with any other column of Datagridview. and i have created that User defined type with native serialization and also made IsByteOrdered to true.

Assembly is sucessfully deployed and i am able to insert and select data in datagridview. only problem while pressing column header of UDT column.

it seems that exception is thrown by sqlserver while comparision. here is the stack trace for exception.

" at System.Data.Common.SqlUdtStorage.CompareValueTo(Int32 recordNo1, Object value)\r\n at System.Data.Common.SqlUdtStorage.Compare(Int32 recordNo1, Int32 recordNo2)\r\n at System.Data.Index.CompareRecords(Int32 record1, Int32 record2)\r\n at System.Data.Index.IndexTree.CompareNode(Int32 record1, Int32 record2)\r\n at System.Data.RBTree`1.RBInsert(Int32 root_id, Int32 x_id, Int32 position)\r\n at System.Data.RBTree`1.Insert(K item)\r\n at System.Data.Index.InitRecords(IFilter filter)\r\n at System.Data.Index..ctor(DataTable table, Int32[] ndexDesc, IndexField[] indexFields, DataViewRowState recordStates, IFilter rowFilter)\r\n at System.Data.DataTable.GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)\r\n at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent)\r\n at System.Data.DataView.UpdateIndex(Boolean force)\r\n at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter, Boolean fireEvent)\r\n at System.Data.DataView.SetIndex(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter)\r\n at System.Data.DataView.set_Sort(String value)\r\n at System.Data.DataView.System.ComponentModel.IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.DataGridViewDataConnection.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.SortInternal(IComparer comparer, DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)\r\n at System.Windows.Forms.DataGridView.OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e)\r\n at System.Windows.Forms.DataGridView.OnMouseClick(MouseEventArgs e)\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.DataGridView.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at testAlarmType.Program.Main() in c:\\Manoj\\CSharp\\Work\\testAlarmType\\testAlarmType\\Program.cs:line 17\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"

let me know if any one has any workaround.

Thanks in advance.

|||I have tried to look at this, and while it seems that IComparable is not used by SQL Server 2005 it is used when ordering DataTables, which seems to be an oversight when the requirements for UDTs were written. I write more in this thread.sql

Wednesday, March 28, 2012

Problem with Boolean Nullable parameter in Report Viewer

I have a problem with a nullable boolean parameter.
By default, the value is Null and that's working fine.

The User clicks either true or false, view the report: fine again.

However, from that point on, if the user checks the Null checkbox and
submits the reports, it reverts automatically back to the last True or
False value.

Is this a known problem? Or am I doing something wrong?

Eric

You aren't doing anything wrong. This is a bug. Unfortunately, there is no workaround. If this is causing you signficant problems, please contact customer support directly for a solution.

http://www.microsoft.com/services/microsoftservices/srv_support.mspx

|||

Thanks for the answer.

Is it reasonable to assume that this will get fixed in the next service pack, whenever this is?

|||I can't make any promises at this point (there are many factors involved), but I am pushing for it.|||Thanks

Problem with Best Practices Analyzer and set nocount on.

Hi.
There is a bug with BPA.
When you configure a server with sp_configure 'user options',512 or EM
(default connection options) seting to NOCOUNT ON, BPA fails when reading
the catalog.
Esio
Thanks Esio for reporting this issue.
We shall work on fixing this issue in future release of BPA
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
"Esio Nunes" <esio_nunes@.hotmail.com> wrote in message
news:%239d5MqL%23EHA.3988@.TK2MSFTNGP11.phx.gbl...
> Hi.
> There is a bug with BPA.
> When you configure a server with sp_configure 'user options',512 or EM
> (default connection options) seting to NOCOUNT ON, BPA fails when reading
> the catalog.
> Esio
>

Monday, March 12, 2012

problem while creating index for temporary table...

Hi,

i have created index for a temporary table and this script should used by multiusers.So when second user connecting to it is giving index i mean object already exists.

So what i need is when the second user connected the script should create one more index on temporary table.Will sql server provide any random way of creating indexes if the index exists already with that name?

Thank You,

Seeing the actual script will be helpful.

What advantage do you think you get from creating multiple (identical) indices on the same table?

|||

Nope..

SQL Server is cleaver enough to handel this situation.

When you create a index or constraint on the Temp Table, eventhough the index name is duplicate it will allow.

But it only possible on temp tables (prefixed with single #).

To Test this,

Open Two window,

Execute the below window on the opened 2 window..

create table #test

(

id int

);

Insert Into #test values(1);

Insert Into #test values(2);

Create clustered index testindex on #test(id)

Now you wont get any error on any of the window. Rite?

To fetch the created index details, execute the below code on any one of the window..

select * from sysindexes where name like '%test%'

Now you can see the 2 rows with same indexname but refereing with different table. Yes. all the temp tables (#) will be suffixed with unique number to avoid the object already found error while multiple users connects.

Problem when trying to deploy a web site built with asp.net 2.0 and using SQL EXPRESS

Hi,

Plz help!

I built a web site using IIS and ASP.NET 2.0.

My web site has a log on screen and I only configured it with one user without any roles. This web site uses the SQL EXPRESS.(I Have 2 databases: 1 for the security required by the application and the other for my application. for the connectionstring I used a windows authentication security with an instance = true.)

Everything went well on my PC.

When I tried to deploy the web site on another PC, there was a big problem.

When I tried to login with the same user I created, then I have a problem.

The password is incorrect(Why? I don't know).

Maybe there is a problem with the IIS or with the SQL SERVER.

pLZ HELP!!

You should take a look at the forum at http://forums.asp.net/54/ShowForum.aspx, which covers Visual Web Designer. They will have a better idea how to address this.

Mike

Friday, March 9, 2012

problem when iserting in table

I'm building a form that collects some info from the user (user name, password and type ) and I need to store this info into a table called USER that I created.

I'm using 3 text boxes and a button, when the user clicks the button I need to collect this info and store it into my table

when i click the button i get an error msg in this line (comm.ExecuteNonQuery(); )

what do i need to do?

here is the code

protectedvoid Button1_Click(object sender,EventArgs e)

{

string str ="data source=(local);initial catalog=NH_Project1;integrated security=true;";

SqlConnection conn =newSqlConnection(str);

int rows;

SqlCommand comm =newSqlCommand("INSERT INTO [USER](UserId, UserName, UserPassword, Type)VALUES" +

"@.UsrName,@.UsrPass,@.UsrType", conn);

comm.CommandType =CommandType.Text;

comm.Parameters.AddWithValue("@.UsrName",TextBox1.Text);

comm.Parameters.AddWithValue("@.UsrPass",TextBox2.Text);

comm.Parameters.AddWithValue("@.UsrType", TextBox3.Text);

conn.Open();

rows= comm.ExecuteNonQuery();

conn.Close();

louayazar:

comm.Parameters.AddWithValue("@.UsrName",TextBox1.Text);comm.Parameters.AddWithValue("@.UsrPass",TextBox2.Text);

comm.Parameters.AddWithValue("@.UsrType", TextBox3.Text);

Remove the "@." symbol from your AddWithValue calls. Also, I'd recommend enclosing your ExecuteNonQuery call within a Try/Catch block so you can capture any errors in the future.

|||

Hii

I tried to remove the "@." like what you said but that doesn't work, I still have the same error MSG when clicking the button.

|||

Then make sure to put your ExecuteNonQuery call into a Try/Catch block and see what exception you get. This should help you find out what's going on.

|||

that was helpful, thanks a bunch