Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2002-12-23 : 13:17:42
|
| Hi. I've got textarea boxes on my ASP form and I'll be sending data in these boxes to my SQL database. I'm trying to figure out what is the best data type matchup between ADO parameters and SQL datatypes that will allow me to pass long character strings (preferably longer than 255 characters) to the database without errors. I was matching ado advarchar with varchar on the sql end but my users need more space for extended narrative and ADO crashes with "truncated" error after string that's > 50.I notice there is no NVARCHAR option in ADO that matches with NVARCHAR in SQL.Any suggestions on which data types to use on ADO side and SQL side for a good match?thx |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-12-23 : 13:35:46
|
| I use VARCHAR to match up with TextArea's. I use client side form validation code to make sure that the user doesn't type in more data than the VARCHAR field allows (usually 250-300). VARCHAR's can go up to 8000, but that might not be enough for your "narritives." You might want to look at the TEXT datatype.The NVARCHAR and NTEXT are used to store UNICODE data, and thus take up twice the space as a VARCHAR or TEXT field for the same amount of input data.NVARCHAR has a max size of 4000, VARCHAR mas a max size of 8000You get the truncated error after 50 characters? That's very odd. Are the users putting any special characters (esp single and double quotes) in their text?Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2002-12-23 : 13:52:39
|
| Michael,Thanks for enlightening me re: the max length varchar can take. I did not know this. 8000 character limit is plenty for my users. Having learned something, I went back to my code and realized there were inconsistencies among the various string lengths I had coded in the ASP page, the SPROC, and SQL server tables. Now these are consistent and the errors are gone.Would it be possible for you to post your TEXTArea validation code? This would be very useful.thanks again. |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-12-23 : 13:56:51
|
| Are you using ASP 3.0 or .Net?<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2002-12-23 : 16:06:37
|
| Classic ASP, 3.0thx |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-12-23 : 16:31:13
|
I have a DLL that I use to dynamically generate this javascript, but I can't give that out. The javascript inside was borrowed from all over. Here's what it outputs: <script Language="JavaScript"><!--function Form_Validator(theForm){ if (theForm.MsgName.value == "") { alert("Please enter a value for the \"Message Name\" field."); theForm.MsgName.focus(); return (false); } if (theForm.MsgName.value.length < 1) { alert("Please enter at least 1 characters in the \"Message Name\" field."); theForm.MsgName.focus(); return (false); } if (theForm.MsgName.value.length > 255) { alert("Please enter at most 255 characters in the \"Message Name\" field."); theForm.MsgName.focus(); return (false); }return (true);}//--></script> In a submit button or in the <form> tag itself, call this function, and pass the form object into this function.Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
|
|
|
|
|