Optimization Gurus: Help With Varchar Vs. Text Fields Decision

Dec 16, 2007

Hi, I'm trying to improve performance for a db that stores messages.  The message is currently stored in an ntext field, but when I look at all the records from the past 3 months, I found that 88% are less than 1000 characters, and 97% are less than 3000 characters. 
I don't want to actually limit the message size, but it seems like I might get much better performance using a varchar(3000) field to hold most of the messages, and a separate text field just used for those 3% that really are long. Is this a good idea?  If so, is it better to put the Message and LongMessage fields in the same table; or, have a separate table to hold the long messages?  If it is in a separate table, it would need to be left joined with the message table each time messages are retrieved.
Also -- I am getting about 700 new messages daily, and right now have over 150,000 messages stored.  The vast majority of activity involves new messages.  Is this a good situation to look at using horizontal partitioning?
Thanks for any help, I don't really have anyone to discuss this with and it is really helpful to get some other views!! 

View 6 Replies


ADVERTISEMENT

Replace Text In Text, Char && Varchar Fields All At Once?

Jan 22, 2008

I have followed many tutorials on selecting and replacing text in text fields, varchar fields and char fields, but I have yet to find a single script that will to all 3 based on field type. Let's assume for a moment that I don't know where all in my database a certain value that I need changed resides ... i.e., the data's tablename and fieldname. How would I go about doing the following ... or more importantly, is this even possible in a SQL only procedure?1) Loop over entire database and get all user tables2) Loop over all user tables and get all fields3) Loop over all fields and determine the field type4) switch between field types and change a string of text from 'a' to 'b'Please be gentle, I'm a procedure newb.

View 9 Replies View Related

Concatenate Text And Varchar Fields

May 29, 2008

I am trying to add a carriage return to the end of a text field through a script. This is what I'm trying:


UPDATE Table_Name SET Column_TEXT = Column_TEXT) + '

' WHERE Column_TEXT = 'Some text'

I also tried

UPDATE Table_Name SET Column_TEXT = Column_TEXT) + '<cr>' WHERE Column_TEXT = 'Some text'

But I keep getting the error

The data types text and varchar are incompatible in the equal to operator.

Help!!

Thanks in advance
Mangala

View 3 Replies View Related

Trying To CONCAT A TEXT Field With 2 VARCHAR Fields - Brick Wall.

Dec 7, 2006

Hi all. I have been going round and round for the past 2 days on this and would appreciate any help. In a view select statement, I need to concat 2 varchar fields with a text field. If I CONVERT the TEXT field to VARCHAR, only the first 30 characters of the field appear in the result set. If I convert the VARCHAR fields to TEXT, I get an error that I cannot CONCAT TEXT fields. I'm not sure what to do. Can someone please offer some assistance? Thanks in advance! Steve

View 1 Replies View Related

TO ALL SQL Gurus TEXT FILE IMPORT VERY VERY URGENT

Nov 16, 2000

Hi Every one.

I have a text file (BEA.Txt) which contains the description of the products. I have the product table as below

Product_Code VarChar(3)
Description Text

I need to add the text from text file BEA.TXT into product table for Product_code = BEA.

DTS DOS NOT WORK !!!. IT ADDS SEVERAL RECORDS TO PRODUCT TABLE. IT CONSIDERS EACH CARRIAGE RETURN AS NEW RECORD IT DOES NOT HELP MEARLY

Please help me
Thanks
Lilly

View 8 Replies View Related

Silly Question - For SQL Gurus And SWYNK Gurus

Nov 3, 2000

Probably this will be a silly question?

1. How can I Put all the Q documents from Microsoft that are related to SQL server? So that I can search fast.

2. How can I search SWYNK for all the ANSWERS that MAK/CRAIG/RAY replied to the threads. Its so weird that I answered someone and now I forgot the answer what I posted. Now I am having the same problem. I cant search.

3. I wanna put all SWYNK's Questions responses in one database say SQLSERVER, so that I can search all the threads.

I had sent many emails to SWYNK. No reply so far.

Any inputs r well appreciated!!!!!!

-MAK

View 2 Replies View Related

Adding A Full Text Search Across Multiple Tables (with Text Fields)

Sep 7, 2007

Hi, i'm trying to do a full text search on my site to add a weighting score to my results.  I have the following database structure:
Documents: - DocumentID (int, PK) - Title (varchar) - Content (text) - CategoryID (int, FK)
Categories: - CategoryID (int, PK) - CategoryName (varchar)
I need to create a full text index which searches the Title, Content and CategoryName fields.  I figured since i needed to search the CategoryName field i would create an indexed view.  I tried to execute the following query:
CREATE VIEW vw_DocumentsWITH SCHEMABINDING ASSELECT dbo.Documents.DocumentID, dbo.Documents.Title, dbo.Documents.[Content], dbo.Documents.CategoryID, dbo.Categories.CategoryNameFROM dbo.Categories INNER JOIN dbo.Documents ON dbo.Categories.CategoryID = dbo.Documents.CategoryID
GOCREATE UNIQUE CLUSTERED INDEX vw_DocumentsIndexON vw_Documents(DocumentID)
But this gave me the error:
Cannot create index on view 'dbname.dbo.vw_Documents'. It contains text, ntext, image or xml columns.
I tried converting the Content to a varchar(max) within my view but it still didn't like.
Appreciate if someone can tell me how this can be done as surely what i'm trying to do is not ground breaking.

View 2 Replies View Related

Parsing Varchar Fields

Sep 24, 2005

What are some good strategic approaches to using freeform text fields fordata that needs to be queried? We have a product whose tables we can'tchange, and I need to count on a "description" field for storing a value.Two, actually. I'm thinking of adopting this convention:InvoiceNumber@VendorAcronymThere'd be a lot of vendors.Additional issue: sometimes these values would be referred to in thedescription field, and I'd need to distinguish them as referrals ratherthan as original recorded instances of the values. For that, I imaginedeither:InvoiceNumber@@VendorAcronymorInvoiceNumber&VendorAcronymInvoiceNumber//VendorAcronymetc. -- something like that.I'm just wondering if there's best practice for doing anything this stupid(hey, I'm stuck with this as our only option just now; hopefully it's onlytemporary). How to parse out whatever I end up implementing -- well, itneeds to be tractable.Thoughts?--Scott

View 21 Replies View Related

Two Int Fields Or One Varchar Field

Jul 20, 2005

I am setting up a database that will receive a lot of data from twoseparate telephone centers, the log table will in a short time haveover 1 million lines, and I was wondering if I should use 1 identifyfield or two:case 1:[Id] [int] IDENTITY (1, 1) NOT NULL[ServerId] [int] NOT NULLcase 2:[Id] [varchar(20)] IDENTITY NOT NULLWhere in case 1 I would just use a combination of Id and ServerId toidentify the line, where in case 2 I would have the Id field a varcharthat would look something like A-000001, A-000002 for server 1 andB-000001, B-000002 for server 2Which solution will be faster when searching for a record when thewill have over 1 million lines?

View 3 Replies View Related

HOw To Order Fields Of Type Varchar?

Mar 22, 2000

I have a varchar field which holds IDs like (1, 3, 5, 19, 23) when I order it, i get it ordered in ASCII order like (1, 19, 23, 3, 5) rather than (1, 3, 5, 19, 23) Even if I convert it to int, I won't be able to order it.

is there any way I can order a varchar field numerically?

Angel

View 1 Replies View Related

JDBC - Varchar Or Nvarchar Fields?

May 10, 2006

Hi, I'm starting a new application in java using JTDS jdbc driver(http://jtds.sourceforge.net) and SQLServer 2005 Express.I have to design the database from scratch and my doubt is if I have to usevarchar or nvarchar fields to store string data.Any experience about performance issues using nvarchar instead of varchar(considering that Java internally works in unicode too)?Thanks in advance,Davide.

View 4 Replies View Related

SQL Server/ Text Fields - Cannot Add Free Text

Sep 25, 2007

I have a data table in my project that has a "text" (not varchar) field in it.  I am trying to load this field with little paragraphs of text for showing on my pages. How do I get the free text loaded into the table?  The database explorer and all the data grid controls cut the text off at one line.  There doesn't seem to be any way to get multiline text into this table.  

View 2 Replies View Related

Concatenated Long Varchar Fields Are Getting Truncated

Mar 30, 2004

(I'm using MS SQL 2000)

I've two tables that I've made from some query subsets. Each table has a varchar field with notes/memos and I want to concatenate the fields into one long field.

The problem I'm running into is that when I run the query to check the concatenation, the field is truncated maybe 256 chars in.

I tried converting and casting the field as nvarchar 4000, and I've also done the same for the fields in the two tables, but that doesn't seem to help.

I can query for the fields from each table and none of them are truncated by themselves. It only happens after I concatenate them.

I've created a new table and inserted the results into it, but the field in it is also truncated.

Am I missing something obvious here?

View 2 Replies View Related

T-SQL (SS2K8) :: Copy Varchar (max) Fields Slow

Mar 13, 2015

I'm archiving some data. In a 2 step process.

1. Copy old data from each table in LiveDB to same table in ArchiveDB.
2. Delete the data from each table in LiveDB which is in ArchiveDB

Both DBs SIMPLE recovery mode.

Each table has a clustered PK on a single int value. In both DBs

The tables with varchar(max) columns are taking a v.long time to copy over.

IS there anything I can change in the ArchiveDB to make it run faster.

It is the insert that is taking the time. I've tried dropping the clustered PKs in ArchiveDB tables and then rebuilding afterwards but it has not made any difference. After all I am adding data to the ArchiveDB in clustered index order, so wouldn't have expected it to.

How I can change the Archive DB but cannot touch the schema/settings of Live DB.

View 9 Replies View Related

Dynamic Filedlength Of Varchar Fields In Source

Nov 21, 2006

I'm using SSIS to import data from a table (SQL) containing varchar fields. The problem is, that those varchar fields are changing over time (sometimes shrinking and sometimes expanding). I.e. from varchar(16) to varchar(20).

When I create my SSIS package, the package seem to store information about the length of each source-field. At runtime, if the field-length is larger then what the package expects an error is thown.

Is there anyway around this problem?

Oh, yeah... My destination fields are a lot wider then the source fields, so the problem is not that the varchar values doesn't fit in my destination table, but that the package expects the source to be smaller...

Regards Andreas

View 3 Replies View Related

Retrieving Varchar(max) And Varbinary(max) Fields With VFP9

Mar 20, 2007

I have a test database that contains a varbinary(max) field and a varchar(max) field.

when I do a

Select * from test where id = xx

I get the expected results if my connection string uses

'driver=SQL Server;Server'

but these two fields return no data if I use

'driver=SQL Native Client'

the other fields in the record come back with no problems.

Is there anything special I need to do to retrieve these types of fields?

View 1 Replies View Related

Converting Varchar To Numeric And Date Fields...

Jan 21, 2008



Hi All,

I have 2 varchar fields on MS 2005 table
First field is date and format is 080118(YYMMDD)
and second is salary field like 00002000(positive) and 00002000- (negative)
how can I move them to date and numeric fields on another table....

thanks

View 1 Replies View Related

SSIS Import Of CSV Don't Recognize NULL Values For VARCHAR Fields

Sep 4, 2007

Hi, i'm new to SSIS and trying to import some csv files (comma delimited) into SQL Server. A NULL value for a CHAR column is correctly regonized as NULl in SQL Server, but a NULL value for of a mapping to a VARCHAR column in SQL Server is not recognized correctly and i get the value "'NULL'" in SQL Server (including the single comma.

Sample:

CSV file contains columns A and B. A and B contains the Text NULL.
Column A is mapped to a CHAR field, and column B is mapped to a VARCHAR field in SQL Server.
After the import, SQL has the following value: A = NULL as NULL, B 'NULL' as text.

did anyone else had this problem?

thanks so much for any help.

View 4 Replies View Related

Table Data Retrieval And Optimization Optimization Help

Apr 10, 2008

Hello Everybody,

I have a small tricky problem here...need help of all you experts.

Let me explain in detail. I have three tables

1. Emp Table: Columns-> EMPID and DeptID
2. Dept Table: Columns-> DeptName and DeptID
3. Team table : Columns -> Date, EmpID1, EmpID2, DeptNo.

There is a stored procedure which runs every day, and for "EVERY" deptID that exists in the dept table, selects two employee from emp table and puts them in the team table. Now assuming that there are several thousands of departments in the dept table, the amount of data entered in Team table is tremendous every day.

If I continue to run the stored proc for 1 month, the team table will have lots of rows in it and I have to retain all the records.

The real problem is when I want to retrive data for a employee(empid1 or empid2) from Team table and view the related details like date, deptno and empid1 or empid2 from emp table.
HOw do we optimise the data retrieval and storage for the table Team. I cannot use partitions as I have SQL server 2005 standard edition.

Please help me to optimize the query and data retrieval time from Team table.


Thanks,
Ganesh

View 4 Replies View Related

Advice Needed : Nasty Problem PHP/MS SQL Server And Varchar Fields &> 255 In Length

Jul 20, 2005

I am currently working on a PHP based website that needs to be able to drawfrom Oracle, MS SQL Server, MySQL and given time and demand other RDBMS. Itook a lot of time and care creating a flexible and solid wrapper and amdeep into coding. The only problem is a noticed VARCHAR fields being drawnfrom SQL Server 2000 are being truncated to 255 characters.I searched around php.net and found the following :Note to Win32 Users: Due to a limitation in the underlying API used by PHP(MS DbLib C API), the length of VARCHAR fields is limited to 255. If youneed to store more data, use a TEXT field instead.(http://www.php.net/manual/en/functi...ield-length.php)The only problem with this advice is Text fields seem to be limited to 16characters in length, and I am having similar results in terms of truncationwith other character based fields that can store more than 255 characters.I am using PHP 4.3.3 running on IIS using the php_mssql.dll extensions andthe functions referenced here http://www.php.net/manual/en/ref.mssql.php.What are my options here? Has anybody worked around this or am I missingsomething obvious?James

View 4 Replies View Related

Text Vs. Varchar

Aug 14, 2007

I have a table with a column of varchar(4000) and another table with 2 columns that are varchar(2000)
 Is it better to make these columns text columns? 
 The 2 varchar(2000) columns do not need to be searched, but many of the other columns in that table do need to be searched.
The varchar(4000) column has a full text index on it.
 Any help would be appreciated
Thank you

View 1 Replies View Related

Text, Varchar Or ???

Sep 15, 2005

Hi ,

 I have a website where we review cds ... the users write their own reviews ...

But when the reviews are displayed on screen all the breaks are gone and all the text comes in one block .
Can anyone advise on what to do ?

I tried to change from varchar to text but it didn't change anything.

Thanks for the help

View 4 Replies View Related

Text And Varchar (max)

Dec 10, 2006

Hello, I have read that microsoft is getting rid of the text datatype and replacing it with varchar. The maximum that varchar can hold is 8000 bytes. Is there a way to get above 8000 bytes without using text?

View 1 Replies View Related

Text Or Varchar ?

Jul 23, 2005

Hi,What is the maximum character a text type column can contain ? Can'tchange the length to upper than 16....What is the bigger ? Varchar(8000) or Text ?Regards

View 2 Replies View Related

How To Convert VARCHAR To TEXT

Mar 18, 2004

Hi all
iam trying to but a varchar variable into a TEXT var but i get this error "The assignment operator operation cannot take a text data type as an argument"

anybody know what shall i do
best regards

View 7 Replies View Related

Blob Text Or Varchar?

Jan 10, 2002

hi everyone a question for all you wise men out there! ;-)

i run a db with thousands of reviews, interviews, article and so on. What's better: 1) leaving all the articles on .txt files and then using the file system object to show them in the page; 2) insert the articles in the db splitting them in several varchar fields 3) insert the articles in the db using the text/blob fields

thanx, it's a very hard question for me!

View 1 Replies View Related

Text Vs. Varchar Fieldtypes

Jun 25, 2001

is it smarter to use the text field type or to use a varchar field type with a length of 100-150? please give me a detailed answer. thanx

View 1 Replies View Related

Replace Varchar Text

Dec 11, 2007

Hello Guys.

Here is my issue i have email addresses in a column of a table in sql server. Are addreses has changed since and i need to do a mass update of these email addreses i need to replace a few char to reflect this change like ex:

AAAAA@BBB.CCC.Com i need to replace the BBB. part with nothing so that it looks like this AAAAA@CCC.Com.

Please help.

View 4 Replies View Related

Convert Text To Varchar

Oct 22, 2007

hi,

i would like to convert text string(field) to varchar so I can use later group by a special string.

what shall i use?

thank you

View 8 Replies View Related

Reading Text Into Varchar

Jul 20, 2005

Hello,I have a column (text datatype) and has to send an email as a text(not attachment) using cdonts. I am reading the data from text columnstoring in a varchar field and saying cdonts.body = [data].This way I can send email to as a text format. Now, my problem is whenlength of data is greater than the 8000 chars it truncates the rest ofthe data.......and email I send is a truncated email.......loosingimporatnt data.How should I resolve this situation.......I am trying some differentideas but not worked yet. Finally, I am writting the entire content ina file and sending it as attachment but the reaquirement is to send itas a body text.Any ideas?Let me know if you need more details!Thanks,-Hayatwww.mysticssoft.com

View 1 Replies View Related

Problem With Datatype Text? Or Very Big Varchar?

Oct 12, 2006

I have the following form in this adress:(it's framework 1.1 asp.net vb.net)http://admin.artemrede.pt/login.aspx?ReturnUrl=%2fdefault.aspxthe utilizador is:  testepalavra passe is: 12345I'm using some text datatypes and some very big varchars the problem is that when you try to add a new record or to edit a existing record, if for example in one of the very big varchars or text, textboxes, several lines of text, It only puts in the database the 2 first words that you write. I used the VS debug and apparently everything looks ok......(if it would I probably hadn't this error....) Dim OurConnection As SqlConnectionOurConnection = New SqlConnection(conn_default)Dim OurCommand As SqlCommandOurCommand = New SqlCommand("Insert Into espectaculo (foto_destaque, thumb, area_prog, nome_espectaculo, coord, nome_comp, duracao, f_etaria, sinopse, iterancia, ficha, bio_interv, bio_comp, link_comp, notas_imprensa) Values (@fotod, @thumb, @areap, @ne, @coord, @nc, @duracao, @fe, @sinopse, @it, @ficha, @bioI, @bioC, @link, @notasp)", OurConnection)If (foto_destaque.Text = "") ThenOurCommand.Parameters.Add("@fotod", SqlDbType.VarChar, 12).Value = " "ElseOurCommand.Parameters.Add("@fotod", SqlDbType.VarChar, 12).Value = foto_destaque.TextEnd IfIf (thumb.Text = "") ThenOurCommand.Parameters.Add("@thumb", SqlDbType.VarChar, 12).Value = " "ElseOurCommand.Parameters.Add("@thumb", SqlDbType.VarChar, 12).Value = thumb.TextEnd IfIf (area_prog.Text = "") ThenOurCommand.Parameters.Add("@areap", SqlDbType.VarChar, 50).Value = " "ElseOurCommand.Parameters.Add("@areap", SqlDbType.VarChar, 50).Value = area_prog.TextEnd IfIf (nome_esp.Text = "") ThenOurCommand.Parameters.Add("@ne", SqlDbType.VarChar, 100).Value = " "ElseOurCommand.Parameters.Add("@ne", SqlDbType.VarChar, 100).Value = nome_esp.TextEnd IfIf (coord.Text = "") ThenOurCommand.Parameters.Add("@coord", SqlDbType.VarChar, 100).Value = " "ElseOurCommand.Parameters.Add("@coord", SqlDbType.VarChar, 100).Value = coord.TextEnd IfIf (nome_comp.Text = "") ThenOurCommand.Parameters.Add("@nc", SqlDbType.VarChar, 50).Value = " "ElseOurCommand.Parameters.Add("@nc", SqlDbType.VarChar, 50).Value = nome_comp.TextEnd IfIf (duracao.Text = "") ThenOurCommand.Parameters.Add("@duracao", SqlDbType.VarChar, 25).Value = " "ElseOurCommand.Parameters.Add("@duracao", SqlDbType.VarChar, 25).Value = duracao.TextEnd IfIf (faixa.Text = "") ThenOurCommand.Parameters.Add("@fe", SqlDbType.VarChar, 50).Value = " "ElseOurCommand.Parameters.Add("@fe", SqlDbType.VarChar, 50).Value = faixa.TextEnd IfIf (sinopse.Text = "") ThenOurCommand.Parameters.Add("@sinopse", SqlDbType.VarChar, 8000).Value = " "ElseOurCommand.Parameters.Add("@sinopse", SqlDbType.Text, 16).Value = sinopse.TextEnd IfIf (itener.Text = "") ThenOurCommand.Parameters.Add("@it", SqlDbType.VarChar, 200).Value = " "ElseOurCommand.Parameters.Add("@it", SqlDbType.VarChar, 200).Value = itener.TextEnd IfIf (ficha.Text = "") ThenOurCommand.Parameters.Add("@ficha", SqlDbType.Text, 16).Value = " "ElseOurCommand.Parameters.Add("@ficha", SqlDbType.Text, 16).Value = ficha.TextEnd IfIf (bio_interv.Text = "") ThenOurCommand.Parameters.Add("@bioI", SqlDbType.Text, 16).Value = " "ElseOurCommand.Parameters.Add("@bioI", SqlDbType.Text, 16).Value = bio_interv.TextEnd IfIf (bio_comp.Text = "") ThenOurCommand.Parameters.Add("@bioC", SqlDbType.Text, 16).Value = " "ElseOurCommand.Parameters.Add("@bioC", SqlDbType.Text, 16).Value = bio_comp.TextEnd IfIf (linkComp.Text = "") Or (linkComp.Text = "http://") ThenOurCommand.Parameters.Add("@link", SqlDbType.VarChar, 100).Value = " "ElseOurCommand.Parameters.Add("@link", SqlDbType.VarChar, 100).Value = linkComp.TextEnd IfIf (notas_press.Text = "") ThenOurCommand.Parameters.Add("@notasp", SqlDbType.VarChar, 5000).Value = " "ElseOurCommand.Parameters.Add("@notasp", SqlDbType.VarChar, 5000).Value = notas_press.TextEnd If   OurConnection.Open()OurCommand.ExecuteNonQuery()OurConnection.Close()carrega()'grid1.DataBind()End IfEnd Sub Sub carrega()conn_default = ConfigurationSettings.AppSettings("ArtemredeConnection")Dim OurConnection As SqlConnectionOurConnection = New SqlConnection(conn_default)OurConnection.Open() Dim OurCommand As SqlCommandDim SelectCommand As StringSelectCommand = "select id_espectaculo, area_prog, nome_espectaculo, nome_comp from espectaculo"OurCommand = New SqlCommand(SelectCommand, OurConnection) Dim Select_DataAdapter As New SqlDataAdapter(OurCommand)Dim Select_DataSet As New DataSet'Dim SP_DataTable_Rowcount As IntegerSelect_DataAdapter.Fill(Select_DataSet, "Espectaculos")grid1.DataSource = Select_DataSetgrid1.DataBind()OurConnection.Close()  End Sub 

View 2 Replies View Related

HELP: Text And Varchar Are Incompatible Agrivation!

Apr 26, 2007

I am trying to do a simple select statement on my db but keep getting the fallowing exception being thrown ...System.Web.Services.Protocols.SoapException was unhandled  Actor=""  Lang=""  Message="System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: The data types text and varchar are incompatible in the equal to operator.   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 RelayService.ValidAccessID(String ID) in C:Documents and SettingsDeanMy DocumentsVisual Studio 2005ProjectsMsgSRXMsgSRXServiceApp_CodeRelayService.vb:line 193   at RelayService.SendMessage(String msg, String AccessID, Int64& MsgID) in C:Documents and SettingsDeanMy DocumentsVisual Studio 2005ProjectsMsgSRXMsgSRXServiceApp_CodeRelayService.vb:line 377   --- End of inner exception stack trace ---"  Node=""  Role=""  Source="System.Web.Services"  StackTrace:       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)       at ChatClient.MsgSRX.RelayService.SendMessage(String msg, String AccessID, Int64& MsgID) in C:Documents and SettingsDeanMy DocumentsVisual Studio 2005ProjectsMsgSRXChatClientWeb ReferencesMsgSRXReference.vb:line 342       at ChatClient.Form1.btnSend_Click(Object sender, EventArgs e) in C:Documents and SettingsDeanMy DocumentsVisual Studio 2005ProjectsMsgSRXChatClientForm1.vb:line 13       at System.Windows.Forms.Control.OnClick(EventArgs e)       at System.Windows.Forms.Button.OnClick(EventArgs e)       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)       at System.Windows.Forms.Control.WndProc(Message& m)       at System.Windows.Forms.ButtonBase.WndProc(Message& m)       at System.Windows.Forms.Button.WndProc(Message& m)       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)       at System.Windows.Forms.Application.Run(ApplicationContext context)       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)       at ChatClient.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)       at System.Threading.ThreadHelper.ThreadStart() ... Here is the source code to the method I am using ... Private Function ValidAccessID(ByVal ID As String) As Boolean        Dim conn As New SqlConnection()        conn.ConnectionString = ConfigurationManager.ConnectionStrings("dbConnect").ConnectionString        Dim cmd As String        cmd = "SELECT AccessID, ExpireTime "        cmd &= "FROM AccessIDNumbers "        cmd &= "WHERE AccessID IN ('" & ID & "')"        ' cmd &= "WHERE AccessID ='@ID'"        Dim C As New SqlCommand(cmd, conn)        ' C.Parameters.AddWithValue("@ID", New SqlTypes.SqlString(ID))        '  C.Parameters.Item("@ID").SqlDbType = SqlDbType.Text        conn.Open()        Dim Count As Integer = 0        Dim reader As SqlDataReader = C.ExecuteReader        Dim expired As Boolean = False        If reader.HasRows Then            While reader.Read                Count += 1                Dim et As SqlTypes.SqlDateTime                et = SqlTypes.SqlDateTime.Parse(reader("ExpireTime"))                Dim ct As New SqlTypes.SqlDateTime(Now)                If ct > et AndAlso expired = False Then expired = True            End While        End If        conn.Close()        C.Dispose()        C = Nothing        conn.Dispose()        conn = Nothing        Return expired = False    End Function ... the problem is with the  cmd &= "WHERE AccessID IN ('" & ID & "')" statement. How Can I get this to work properly!!! My data types for the AccessIDNumbers table are as fallows ..UserName -> text -> nulls not allowedAccessID -> text -> nulls not allowedCreationTime -> datatime -> nulls not allowedExpireTime -> datatime -> nulls not allowedCurrentTable -> text -> nulls allowedI don't understand why I'm getting this error!!! 

View 3 Replies View Related

Data Type Varchar And Text

Oct 27, 2007

I encounter this particular error.
Exception Details: System.Data.SqlClient.SqlException: The data types varchar and text are incompatible in the equal to operator.
Line 21:             Dim reader As SqlDataReader = command.ExecuteReader() 
This is the first time I'm trying out with MS SQL so I'm abit lost. I hope my code is correct and I've did a little search. I did not set "Text" in my database, I use int and varchar. Here's the affected part of my code and the database. Dim password As String = ""
Dim querystring As String = "SELECT Password FROM Member WHERE Username = @username"

'Dim conn as SqlConnection
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("mainconnect").ConnectionString)
Dim command As New SqlCommand(querystring, conn)
command.Parameters.Add("@username", SqlDbType.Text)
command.Parameters("@username").Value = txtLogin.Text
conn.Open()

Dim reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
password = reader("Password").ToString()
End While

reader.Close()

End Using
 
My database:
User_ID int(4)
Username varchar(50)
Password varchar(255)
Email varchar(50)
 
Any ideas?

View 2 Replies View Related







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