|
Image and VarBinary are two different column types. You should use SqlDbType.VarBinary if that is what is defined in the DB structure.
Image: Stored out of band (not on the same page as the other table data) and can be up to 2 gigs in size.
VarBinary: Stored with the other table data and limited by page size ~8000 bytes give or take your other columns.
Not sure if these descriptions changed with 2005.
|
|
|
|
|
According to the SQL Server 2005 BOL the image datatype is going to be removed in future versions of SQL Server, which is why I in the database I set the field type to varbinary(max), which indicates maximum storage is 2^31-1 bytes. The same problem still occurs in the program if I run it using
param_arr2[7] = new SqlParameter ("@jacket", SqlDbType.VarBinary); I still get the same exception "Parameterized Query ... expects parameter @jacket, which was not supplied."
Is there any way to set this up to have to parameter use as much space as is necessary to store the image?
Thanks for the help.
- Aaron
|
|
|
|
|
Quoting from MSDN:
"For variable-length data types, Size describes the maximum amount of data to transmit to the server. For example, for a Unicode string value, Size could be used to limit the amount of data sent to the server to the first one hundred characters."
So, you should set the size to the largest expected size you can handle.
For updates, set the size later (just before using it in the sqlCommand):
((SqlParameter)param_array[7]).size = mydata.length;
|
|
|
|
|
SELF JOIN is a type of OUTER JOIN .The difference is that of SELF JOIN,The same table is joined?
srushti08
|
|
|
|
|
Correct. The table is joined upon itself. Typically you will have a field in the table that is used to store a PK value for another record in the table for a row that you are currently either storing or updating. For example, I have a table that is called SECURITY table. It contains a list of all securities that are traded and need to be maintained within the system. One of the columns on the table is called 'underlying_security'. When an option type security is being stored, the underlying_security field will contain the PK value for the underlying equity of the option. A query might be as follows
select ...
...
from security opts
,security unds
...
where opts.underlying_security = unds.security_code
...
In this case the column security_code is the primary key on the security table.
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
When you delete a table,its strututral definition,data,indexes,views,constraints are permanently deleted from a database?
srushti08
|
|
|
|
|
Yes, usually...
In SQL Server, you can setup a 'View' in such a way that it prevents a participating table from being deleted...I think!
Unless you store the schema of a table in some other way, the structural definition will be lost too.
Steve
|
|
|
|
|
If you use "drop table", yes. If what you really want to do is just remove all the data, you should use "truncate table..."
|
|
|
|
|
Sounds like a school question. All data and schemas are deleted, however views won't be removed, you may get a warning however and the delete won't work if you have SCHEMABINDING in your views. Constraints will stop the delete working too, so they'll need to be removed from other questions.
Try deleting a table, that's the easiest way to find out.
|
|
|
|
|
Hi,
I have a couple of VBA modules I need to convert to a SQL 2005 udf (or a C# class if that is abetter place for it!).
The VBA code is below:
Function RMSBetaDist(x, alpha, beta, rate)
'Main function where the cumulative Beta distribution is assembled
datasize = Range("Datsize")
Dim bt() As Double
Dim RMSBeta() As Double
Dim i As Integer
ReDim bt(datasize)
ReDim RMSBeta(datasize)
For i = 1 To datasize
If x(i, 1) < 0 Or x(i, 1) > 1 Then
'Error = MsgBox("There is a problem with the x value of the beta function", vbOKOnly)
'GoTo Abend
x(i, 1) = 1
End If
If x(i, 1) = 0 Then
bt(i) = 0
RMSBeta(i) = 0
GoTo Nextarray
ElseIf x(i, 1) = 1 Then
bt(i) = 0
RMSBeta(i) = 1
GoTo Nextarray
Else
bt(i) = Exp(RMSGammaln(alpha(i, 1) + beta(i, 1)) - RMSGammaln(alpha(i, 1)) - RMSGammaln(beta(i, 1)) + alpha(i, 1) * Log(x(i, 1)) + beta(i, 1) * Log(1 - x(i, 1)))
End If
If x(i, 1) < (alpha(i, 1) + 1) / (alpha(i, 1) + beta(i, 1) + 2) Then
RMSBeta(i) = bt(i) * RMSBetaCF(x(i, 1), alpha(i, 1), beta(i, 1)) / alpha(i, 1)
Else 'symmetry relation I(a,b)=1-I(b,a) where I() is the incomplete beta function
RMSBeta(i) = 1 - bt(i) * RMSBetaCF(1 - x(i, 1), beta(i, 1), alpha(i, 1)) / beta(i, 1)
End If
Nextarray:
RMSBetaDist = RMSBetaDist + rate(i) * (1 - RMSBeta(i))
Next i
Abend:
End Function
Function RMSGammaln(xg) 'Lanczos gamma approximation
'Used in the Beta distribution approximation
Dim y, temp, serial, PI, small As Double
Dim coeff(6) As Double
Dim j As Integer
PI = 3.14159265358979
coeff(0) = 76.18009173
coeff(1) = -86.50532033
coeff(2) = 24.01409822
coeff(3) = -1.231739516
coeff(4) = 0.00120858003
coeff(5) = -0.00000536382
small = 0
If xg < 1 Then
small = xg
y = xg - 1
Else
y = xg - 1
End If
temp = y + 5.5
temp = temp - (y + 0.5) * Log(temp)
serial = 1
For j = 0 To 5
y = y + 1
serial = serial + coeff(j) / y
Next j
If small <> 0 Then 'formula for values of x < 1
RMSGammaln = -temp + Log(Sqr(2 * PI) * serial)
Else
RMSGammaln = -temp + Log(Sqr(2 * PI) * serial)
End If
End Function
Function RMSBetaCF(x2, alpha2, beta2)
'Used to approximate the integral portion of the cumulative Beta distribution
Dim errorf As Double
Dim qap, qam, qab, em, temp, d As Double
Dim bz, bm, bp, bpp As Double
Dim az, am, ap, app, aold As Double
Dim m, MaxIterations As Integer
errorf = 0.0000001
MaxIterations = 1000
bm = 1
az = 1
am = 1
qab = alpha2 + beta2
qap = alpha2 + 1
qam = alpha2 - 1
bz = 1 - qab * x2 / qap
For m = 1 To MaxIterations
em = m
temp = em + em
d = em * (beta2 - em) * x2 / ((qam + temp) * (alpha2 + temp))
ap = az + d * am
bp = bz + d * bm
d = -(alpha2 + em) * (qab + em) * x2 / ((qap + temp) * (alpha2 + temp))
app = ap + d * az
bpp = bp + d * bz
aold = az
am = ap / bpp
bm = bp / bpp
az = app / bpp
bz = 1
If Abs(az - aold) < errorf * Abs(az) Then
GoTo FinalStep
End If
Next m
ErrorStep:
'Error = MsgBox("Either alpha or beta is too big or the maximum iterations are too small for convergence", vbOKOnly, "Problem in RMSBetaCF function")
RMSBetaCF = 1
GoTo Abend
FinalStep:
RMSBetaCF = az
Abend:
'Msg = MsgBox(m & " iterations ", vbOKOnly)
End Function
Any help with this would be greatly appreciated!
Thanks,
Guytz72
|
|
|
|
|
Hi every one,
I'm programming with C# (visual studio 2005) and I have a variable that it's data type is byte array (for example byte[] MyVar),
I have a table in sql server 2005 and it has a field and I'd like to insert MyVar into this field but I don't know what data type should I select in database for this field (for example varbinary,sql_variant ,...)
I mean for insert and retrieve byte[] data type from C# in sql server which data type should I define?do I need any conver in C#?
Please Help me.
Yours Sincerely.
Orchid
|
|
|
|
|
|
what is the deferunt between login and user
|
|
|
|
|
The login is for authentication, the user is for authorization.
|
|
|
|
|
I'm wondering if someone could help me with the SQL I'd need to accomplish the following: I have a db with a number of text fields and what I want to do is have a search box in my program that will search all fields for the text entered. For example I have first_name, last_name, alias, etc. and let's say I enter "Jim" in the search field. I want to be able to search all the fields (first_name, last_name, etc) for that term. Is this possible? I'd also like to use the LIKE operator so the text doesn't have to be exact.
Thanks!
- Aaron
|
|
|
|
|
Maybe something like this:
Select * from table where first_name like '%searchString%' or last_name like '%searchString%' or ....
Or
Select * from table where first_name + last_name + .... like '%searchString%'
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
|
|
|
|
|
That seems to work quite well. Wondering if you could help with another question...how would I make the search string dynamic, as in I want to be able to pass in the value as a paramter...can I do this, if so what's the syntax?
Thanks very much for the help.
- Aaron
|
|
|
|
|
I did not get it. Could you explain a little more about what you want to do?
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
|
|
|
|
|
Sure. This is basically what my T-SQL looks like:
SELECT * FROM dbo.Books
WHERE title LIKE '%search%' OR author LIKE '%search%' What I want to do is be able to pass in "search" as a parameter. I'm not sure how to do this though because if I remove the quotes around the search sting and add the @ in front of it, I get a syntax error. I hope that's clearer.
Thanks again for the help.
- Aaron
|
|
|
|
|
Maybe something like this:
Declare @a varchar(50)<br />
<br />
SELECT * FROM dbo.Books<br />
WHERE title LIKE '%' + @a + '%' OR author LIKE '%' + @a + '%'
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
|
|
|
|
|
Hello! I have been using Datasets and DataAdapters by dragging and dropping on my form. Now I have created a public class and created a dataset by code and filled it wit a Dataadapter. Dataset contains one table "DEPARTMENT" with columns "D_ID" and "D_NAME". Dataset is filled and contains data but when in windows form i tried to bind a combobox to that table it creates problems.
1) dim ClassObj as new DSClass
2)CobmoBox1.datasource = ClassObj.Dataset1.Tables("DEPARTMENT")
3)CobmoBox1.DisplayMember = ?????????????????????????
4)CobmoBox1.DisplayMember = ?????????????????????????
Lines 3,4 creates problems, Please guide me
as900197
|
|
|
|
|
One should be DisplayMember (the column that you want displayed in your combo), the other should be ValueMember (the column that represents the data you want to store).
For example, if you have a table with columns ID and Description, you could set your DisplayMember to 'ID' and your ValueMember to 'Description'.
On your form, you will see the value in the Description displayed in your combo but you will actually store the corresponding ID when updating your DataSet.
CobmoBox1.DisplayMember = "ID"
CobmoBox1.ValueMember = "Description"
Steve
|
|
|
|
|
Thanks Steve!
It was so little mistake and i get so depressed....
Thank you
as900197
|
|
|
|
|
You are welcome.
Upon reading my answer again, I actually got the values the wrong way round!
You would normally have the DisplayMember = "Description" and the ValueMember = "ID".
Steve
|
|
|
|
|
MS ACCESS HELP Listing -> "If the DataType property is set to Text, enter a number from 0 to 255. "
Anybody know how to deal whit this, to make it higher than 255?
Or maybe how to set Memo type at least?
Regards!
|
|
|
|
|