Object Convert To String....

Jul 17, 2007

Hello all,
Currently i am having problem with the conversion from object to string. I am using SqlCommand to draw data from DB, and the statement i used is:
String ires = myCommand.ExecuteScalar().ToString();
and then convert ires to int by int.Parse(ires) 
I have got no problem during the compilation, but it gives me the exception during the runtime...
any one got any ideas? Thanks 

View 11 Replies


ADVERTISEMENT

User Defined Function: Convert String Value Of Table To Table Object

Jul 20, 2005

Does anyone know where to find or how to write a quick user defined fucntionthat will return a table object when passed the string name of the tableobject. The reason why I want dynamicallly set the table name in a storedprocudue WITHOUT using concatination and exec a SQL String.HenceIf @small_int_parameter_previous = 1 then@vchar_tablename = "sales_previous"else@vchar_tablename = "sales"Endselect * from udf_TableLookup(@vchar_tablename )So if I pass 1, that means I want all records from "sales_previous"otherwise give me all records from "sales" (Sales_Previous would last yearssales data for example).udf_TableLookup would I guess lookup in sysobjects for the table name andreturn the table object? I don't know how to do this.I want to do this to avoid having 2 stored procedures..one for current andone for previous year.Please respond to group so others may benfiit from you knowledge.ThanksErik

View 2 Replies View Related

Object Reference Not Set To An Instance Of An Object. And Connection String

Feb 18, 2007

Hi, I am deploying my web through a web hosting services which provides SQL database support. I got following errors whenever I try to open my webpage,which never happen when I run my web on the local machine.  I have my connection string configured in my web.config as below:
<add name="ArtHouseConnection" connectionString="Server=serveripaddress; Integrated Security=True; Database=arteh3_database;User Id=username;Password=password;" providerName="System.Data.SqlClient"/>
<add name="ASPNETDBConnectionString1" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
This is the source code where error was generated:
public static class ArtHouseConfiguration
{
//cache connection string
private readonly static string dbConnectionString;
//cache data provider name
private readonly static string dbProviderName;
private readonly static string siteName;
//initialize constructor properties
static ArtHouseConfiguration()
{
dbConnectionString = ConfigurationManager.ConnectionStrings["ArtHouseConnection"].ConnectionString;
dbProviderName = ConfigurationManager.ConnectionStrings["ArtHouseConnection"].ProviderName;
siteName = ConfigurationManager.AppSettings["SiteName"];
}
and finally this is the error mg I got:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:




Line 30: static ArtHouseConfiguration()
Line 31: {
Line 32: dbConnectionString = ConfigurationManager.ConnectionStrings["ArtHouseConnection"].ConnectionString;
Line 33: dbProviderName = ConfigurationManager.ConnectionStrings["ArtHouseConnection"].ProviderName;
Line 34:
Source File: d:inetpubvhostsartehouse.orghttpdocsApp_CodeArtHouseConfiguration.cs    Line: 32 Stack Trace:




[NullReferenceException: Object reference not set to an instance of an object.]
ArtHouseConfiguration..cctor() in d:inetpubvhostsartehouse.orghttpdocsApp_CodeArtHouseConfiguration.cs:32

[TypeInitializationException: The type initializer for 'ArtHouseConfiguration' threw an exception.]
ArtHouseConfiguration.get_EnableErrorLogEmail() in d:inetpubvhostsartehouse.orghttpdocsApp_CodeArtHouseConfiguration.cs:74
Utilities.LogError(Exception ex) in d:inetpubvhostsartehouse.orghttpdocsApp_CodeUtilities.cs:100
ASP.global_asax.Application_Error(Object sender, EventArgs e) in d:inetpubvhostsartehouse.orghttpdocsGlobal.asax:20
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.HttpApplication.RaiseOnError() +182

Anyone got any ideas? thank you!

View 2 Replies View Related

SIMPLE Command To Convert String To Number? Not CAST Or CONVERT.

Aug 15, 2006

Dear Experts,Ok, I hate to ask such a seemingly dumb question, but I'vealready spent far too much time on this. More that Iwould care to admit.In Sql server, how do I simply change a character into a number??????In Oracle, it is:select to_number(20.55)from dualTO_NUMBER(20.55)----------------20.55And we are on with our lives.In sql server, using the Northwinds database:SELECTr.regionid,STR(r.regionid,7,2) as a_string,CONVERT(numeric, STR(r.regionid,7,2)) as a_number,cast ( STR(r.regionid) as int ) as cast_to_numberFROM REGION R1 1.00112 2.00223 3.00334 4.0044SELECTr.regionid,STR(r.regionid,7,2) as a_string,CONVERT(numeric, STR(r.regionid,7,2) ) as a_number,cast (STR(r.regionid,7,2) as numeric ) as cast_to_numberFROM REGION R1 1.00112 2.00223 3.00334 4.0044Str converts from number to string in one motion.Isn't there a simple function in Sql Server to convertfrom string to number?What is the secret?Thanks

View 4 Replies View Related

Please Help If You Can, Converting String To Object

Apr 20, 2008

I have been working on this all day and cannot find an answer
I need to convert a string to an object, a string to object of type Command
Is there anyway to do this?
Thank you all in advance!!!!!!!

View 1 Replies View Related

CS0266: Cannot Implicitly Convert Type 'object' To 'bool'. An Explicit Conversion Exists (are You Missing A Cast?)

Apr 20, 2008

Using OnSelected on the SqlDataSource----here is my currect code:private void On_Load(Object sender, SqlDataSourceCommandEventArgs e){if (e.Command.Parameters["@DueDate"].Value = "NULL"){e.Command.Parameters["@DueDate"].Value = "0000-00-00 00:00:00.000";}}
I am trying to change the value from  NULL(in a datetime field) to "0000-00-00 00:00:00.000" for use on the page.Any ideas, suggestions, or thoughts would be greatly appreciated!
,Gary"we truly fail, only when we quit."

View 2 Replies View Related

Convert A String To Int?

Jul 10, 2014

using sql 2008, trying to convert a string to int

Example

Table1 has a varchar which i want to cast to int
00125000000 to int 125000000
i used the following
cast(B.[Assessment] as int) as [USER1_01],

with the result 125000000

Table2 has the same field in a different format.

0.00125

i need to find a way to convert one of them so they both match. if i did a join and matched the fields.

I tried

cast (10000000000 * cast([USER1_01] as NUMERIC(6,6)) as INT) as [USER1_01]

but for some reason it dosent look like they match, although they look the same. maybe a type problem?

View 3 Replies View Related

How To Convert A Number To String In SQL?

Jul 7, 2006

I search the help for T-sql, still don't know how to convert a number, for example 12345 to a string with formating like 12,345
Thanks for your help.

View 1 Replies View Related

Convert SqlDataSource To String.

Aug 1, 2007

I'm working with an SqlDataSource, and I'm just wondering how to get the data to a String if I'm sure the select statement will only return 1 piece of data. Any ideas?

View 2 Replies View Related

How To Convert Null To A String

May 12, 2004

I want all the null (blank) values returned by a stored procedure to be shown as a string like "n/a", how to do that easily? Thanks

View 2 Replies View Related

How To Convert String To DateTime

Jan 2, 2006

hi , i have a problem
i have an textarea that i want to convert to DateTime format (dd/MM/yyyy) .
the data in the textarea is (dd/MM/yyyy for example 21/12/2005).
i need it to add this data in sql server , in smalldatetime formation colum .
plz help.
 
 

View 2 Replies View Related

How To Convert A Hex String To An Integer?

Feb 1, 2000

Hi folks,
I'm trying to import data from a text file (UnicodeData.txt) into
an SQL table. Some of the fields are unicode values (16 bits)
expressed as four hexidecimal digits. I've succeeded in importing
the data as character strings, but I have not found a way to convert
them into numbers. (They could be stored as int or nchar.)
I've tried convert(binary/int/whatever, string); E.g.
select convert(int, '0x1111') from import_unicode
gives the error
Syntax error converting the varchar value '0x1111' to a column of data type int.

I could write code to strip off one character at a time, convert the
hex digit to a decimal value, shift left, etc., but I find it hard
to believe that's the best way.

Any help is appreciated. Please email answer to lars_huttar@sil.org
as I don't read this board.

Thanks,
Lars Huttar
lars_huttar@sil.org

View 3 Replies View Related

Convert String To Date In DTS

Dec 7, 1999

I'm using SQL 7.0 SP1.

I am using DTS to read in a date with the format of YYYYMMDD. I am trying to convert this date to MM/DD/YYYY and then use the CDate function with the following code to load it into a Datetime column in SQL Server:

Function Main()
strDate = DTSSource("Col002")
strYear = Left(strDate, 4)
strMonth = Mid(strDate, 5, 2)
strDay = Right(strDate, 2)

strHoldDate = strMonth + "/" + strDay + "/" + strYear

DTSDestination("DateName") = strHoldDate
Main = DTSTransformStat_OK
End Function

My DTS package will execute without errors, but it does not add the row. I have been successful using CDate when the source date is in the format MM/DD/YYYY.

Also, do you have any tips on how to debug DTS? How to see what's in a variable, etc.?

Thanks!
Lisa

View 1 Replies View Related

Convert String To Hex And Concatenate With

Sep 4, 2014

To start, I am NOT a SQL programmer. I have to do some minimal SQL administration (DB Creation, Backups, Security) on spatial databases that are for the most part managed by a 3rd party program. My experience with T-SQL is mostly simple tasks (i.e. Select and Update statements)..However I have been requested to calculate an ID Field using the values of two other fields. Per the request, I need to convert one field to Hex and concatenate with the second field.

ex. Field 1 + Field 2(hex string) = Field 3
Field 1 = 'FF02324323'
Field 2 = 'Smith Creek'
Field 3 = 'FF02324323536D69746820437265656B'

Field 1 VarChar(10) (Code)
Field 2 VarChar(65) (Common Name)
Field 3 VarChar(max) (ResourceID)

Spent half the day searching and have tried various forms of CAST, CONVERT, fn_varbintohexstr and others but have unable to come up with the correct combination to get what I need.

View 3 Replies View Related

Convert To Date From String

Oct 29, 2014

In our ERP system we have a field which is a date-picker in the user front end, but the value is stored in an NVARCHAR field and not always consistently. How can I convert this to a date (preferably in the format YYYY-MM-DD HH:MM) that I could use in a calculation?

select code, spec_value from spec_checklist_remind where spec_checklist_id = 17

code spec_value
------------ -----------------------------------------------------------------------
05MC0001 22/07/2014
05MC0002 23/07/2014
06MT0001 01-May-2014
06MT0002 01-May-2014
06MT0006 01/05/2014
06MT0007 01-May-2014
06MT0008 01/05/2014

View 5 Replies View Related

How To Convert String To Number

Dec 6, 2014

I have a column which keeps numeric data in form of String, but I want to convert it to number e.g. from "1001" to 1001,

Which function I can use to do it?

[URL] .....

View 2 Replies View Related

Can I Convert/reference A String To A Var?

Jul 13, 2006

hey, guys

I got a strange question. :)

In SQL Server,
declare @Item8 as varchar(100)
declare @str as varchar(100)
set @str = '@Item8'
Is there any way I can reference @str to @Item8 ?

Thanks

View 1 Replies View Related

How To Convert A Bit String To 0x Number?

Jul 19, 2006

hi,

I have a bit string like '000111010101101110000111' , how to convert it to varbinary format like 0x1D5B83?

Thanks.

View 1 Replies View Related

Convert String To Smalldatetime

May 4, 2007

Hi,



I am new to SSIS and have been trying to load a date from a Table1.ColumnA (varchar(50)) to a Table2.ColumnB(smalldatetime).



I tried using the Derived Column and Data Conversion controls but I get the below error.

Error converting data type DBTYPE_DBTIMESTAMP to datetime



What do I do to load this data.



Thanks,

Noel

View 8 Replies View Related

Convert String To Numeric

Jul 29, 2007



Hi all,
I defined an user string type varible in the package as AccountLen. I am trying to use this varible in the Expression of Derived Column transformation.
I want to retrieve a part of column, i.e: Right(Column1, @AccountLen), this is always wrong because the AccountLen is string type. How I can convert it to the numeric so that can be used in the RIGHT function?
Thanks

View 3 Replies View Related

Convert From Binary To String

Jan 15, 2008

Hi Everyone -
iam facing a small problem i want to convert an output from the context_info() which is binary to string (or int)

example:

SET CONTEXT_INFO 3


select CONTEXT_INFO() --- it will return 0x0000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

the requested output is to be 3 again


thanx
Maylo

View 3 Replies View Related

Query To Convert String To Int

Oct 4, 2007



CREATE TABLE USERTABLE(
USERID int,
USERNAME varchar(20));

INSERT INTO USERTABLE VALUES (1,'x');
INSERT INTO USERTABLE VALUES (2,'y');
INSERT INTO USERTABLE VALUES (3,'z');


CREATE TABLE ACCESSTABLE(
ACCESSTYPE varchar(50),
USERIDS varchar(20));

INSERT INTO ACCESSTABLE VALUES('Enabled Users','1,2');
INSERT INTO ACCESSTABLE VALUES('Disabled Users','3');

Select USERNAME from USERTABLE where USERID IN (select USERIDS from ACCESSTABLE where ACCESSTYPE='Enabled Users');


I get the following error for the above query.

Syntax error converting the varchar value '1,2' to a column of data type int.


Please advice me.

View 1 Replies View Related

Cannot Convert From Unicode To String

Dec 8, 2007



Hi,

I am getting an issue when i try to run a package which was validated against an oracle database on windows with UTF8. When I try to run the same package(no changes, just changing the conenction parameters to point to an oracle database on UNIX with UTF16), the package fails with error saying cannot convert unicode to string for string columns.
The same run through fine if I refresh the metadata against the UNIX database, but then it doesnt run against the Windows database.

Can anyone please suggest how to overcome this scenario. My issue is, I need to run my package against various database(by just pointing the database connection details) without changing anything in the package.

Please suggest.

Thanks,
Manish

View 5 Replies View Related

Unable To Cast Object Of Type 'System.String' Error Help

Aug 1, 2007

Unable to cast object of type 'System.String' to type 'System.Web.UI.DataSourceSelectArguments'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Web.UI.DataSourceSelectArguments'. 
Hi, In my pageload i have data retriving from a page and i want it to load it in the GridView. i have GridView and SqlDataSource but when the page loads i am getting the above error. i am not sure what im doing wrong here. i tried different ways. but no luck Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Thenfp = CType(Context.Handler, Member)
'lblEmail.Text = fp.EMM.ToString
'this labelbox for Email address is under the Name'lblEmail.Text = fp.EmailAddress.ToString
 
 Dim conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("imacstestConnectionString").ConnectionString)
Dim cmd As SqlCommand = New SqlCommand("SELECT , [fname], [mname], [lname], [address], [city], [state], [zip], [phone] FROM [t_CustomerAcct] WHERE = @email", conn)cmd.Parameters.AddWithValue("@email", fp.EMM.ToString)
conn.Open()
SqlDataSource1.Select(cmd.ExecuteScalar())
'.ExecuteScalar()
 
conn.Close()
End If
End Sub

View 1 Replies View Related

Trouble Converting A Varbinary (Object) To A String Through Script Task

Dec 9, 2006

I have an Execute SQL Task that queries for the contents of a file (which is declared as a varbinary type). My SSIS package needs to write these contents into a temporary location, so what I do is that I pass the result into a System.Object variable. I then use that variable in a Script Task.

Problem is whenever I execute my script task and DirectCast or CType the variable to a string (which is what the contents of the file is), I get a "Conversion from type '_ComObject' to type 'String' is not valid."

Any ideas on how to go about this problem?

View 1 Replies View Related

Convert INT Value To STRING So I Can Add It To Another STRING

Aug 24, 2005

I'm trying to figure out how to convert an INT so that I can add it to another string in a statement likeSELECT '<a href="http://mydomain.com/' + [IntValue] + '">' + [LinkName]Where [IntValue] is an INT field containing a folder number.  I tried: TO_CHAR([IntValue, '999')but it didn't work. And I tried to find a TO_STRING function, but had no luck.Any advice to someone who is savy, but new to SQL Queries?

View 2 Replies View Related

How To Convert Float To Varchar Or String..

Feb 12, 2007

I've three columns:
Length          Width            Height
1.5                  2.5              10
2                   3.7                19
 
in Query I want to display Like 1.5 X 2.5 X 10 (Length, Width, Height).....
 
???

View 1 Replies View Related

How To Convert Literal String To Unicode ?...

Aug 6, 2007

Hi,
I want to convert literal string to unicode before insert into the database. and after insertion i want to retrive this value from data base and convert back to literal string.
pls tell me how to incode and decode literal string to unicode and from unicode to literal string.

View 2 Replies View Related

Convert Text To String In SQL Query

Jun 16, 2008

Hi Everyone,My SQL Query is :"select Field1 from table1"The Field1 in Database is of Type "nvarchar" . I need to convert this Field into "integer" in the Query itself.Please Help!!I have already tried "Select convert(int, Field1 ) from table1"The field gives zero output ThanksRegardsNavdeep  

View 4 Replies View Related

Convert String Into Sql Date Time

May 13, 2004

i have a sql statement that i created in code and it is sending a query to the database
when i dim the variable a datetime variable it says that it cant convert it
if i make the variable a varchar it works but it only returns one result when it should be returning about 10

here is the code


Public Function dbDGQSSearch(ByVal BatchID As String, ByVal CreatedBy As Integer, ByVal CreatedFor As Integer, ByVal DateCreatedMod As Integer, ByVal DateCreated As String, ByVal DateCompletedMod As Integer, ByVal DateCompleted As String, ByVal DateStartedMod As Integer, ByVal DateStarted As String, ByVal SearchType As Integer, ByVal Completed As Integer, ByVal PriorityMod As Integer, ByVal Priority As Integer, ByVal RemainingCallsMod As Integer, ByVal RemainingCalls As Integer, ByVal TotalCallsMod As Integer, ByVal TotalCalls As Integer, ByVal Bonus As Integer, ByVal Keyword1 As String, ByVal Keyword2 As String, ByVal Keyword3 As String, ByVal Keyword4 As String, ByVal Keyword5 As String)

Dim strQueSearch As String
strQueSearch = "SELECT tlkup_Rep.RepID, tlkup_Rep.PositionID, tlkup_Rep.RepFName, tlkup_Rep.RepLName, tlkup_Rep.RepPassword, tlkup_Rep.RepUserName, tlkup_Rep.RepFName + ' ' + tlkup_Rep.RepLName AS RepName, t_Que.QueID, t_Que.BatchID, t_Que.AdminID, t_Que.Manager, t_Que.BonusID, t_Que.QueCompleted, t_Que.QueDate, t_Que.QueNotes, t_Que.QuePriority, t_Que.QueQuantity, t_Que.QueStartDate, t_Que.Mail, t_Que.QueDateComplete, t_Que.QueTotal FROM t_Que INNER JOIN tlkup_Rep ON t_Que.Manager = tlkup_Rep.RepID AND t_Que.Manager = tlkup_Rep.RepID WHERE BatchID<>'' and BatchID<>'2' and BatchID<>'3' and BatchID<>'4' "


'Creates statement for selecting the add to batch data where the criteria appear
If BatchID <> "" Then

strQueSearch = strQueSearch + " and t_Que.BatchID= @BatchID "
End If
If CreatedBy > 1 Then
strQueSearch = strQueSearch + " and t_Que.RepID =@RepID "
End If
If CreatedFor > 1 Then
strQueSearch = strQueSearch + " and t_Que.Manager = @Manager "
End If

If DateCreated <> "" Then
If DateCreatedMod = 0 Then
'>
strQueSearch = strQueSearch + " and t_Que.QueDate >@QueDate "
ElseIf DateCreatedMod = 1 Then
'<
strQueSearch = strQueSearch + " and t_Que.QueDate <@QueDate "
ElseIf DateCreatedMod = 2 Then
'=
strQueSearch = strQueSearch + " and t_Que.QueDate =@QueDate "
End If
End If

If DateCompleted <> "" Then
If DateCompletedMod = 0 Then
'>
strQueSearch = strQueSearch + " and t_Que.QueDateComplete >@QueDateComplete "
ElseIf DateCompletedMod = 1 Then
'<
strQueSearch = strQueSearch + " and t_Que.QueDateComplete <@QueDateComplete and t_Que.QueDateComplete >'1/1/1900' "
ElseIf DateCompletedMod = 2 Then
'=
strQueSearch = strQueSearch + " and t_Que.QueDateComplete =@QueDateComplete "
End If
End If

If DateStarted <> "" Then
If DateStartedMod = 0 Then
'>
strQueSearch = strQueSearch + " and t_Que.QueStartDate >@QueStartDate "
ElseIf DateStartedMod = 1 Then
'<
strQueSearch = strQueSearch + " and t_Que.QueStartDate <@QueStartDate "
ElseIf DateStartedMod = 2 Then
'=
strQueSearch = strQueSearch + " and t_Que.QueStartDate =@QueStartDate "
End If
End If


If SearchType = 0 Then
'Both
'strQueSearch = strQueSearch + " and t_Que.Mail=0 and t_Que.Mail=1 "
ElseIf SearchType = 1 Then
'Mail
strQueSearch = strQueSearch + " and t_Que.Mail=1 "
ElseIf SearchType = 2 Then
'Phone
strQueSearch = strQueSearch + " and t_Que.Mail=0 "
End If

If Completed = 0 Then
'Both
'strQueSearch = strQueSearch + " and t_Que.Mail=0 and t_Que.Mail=1 "
ElseIf Completed = 1 Then
'Yes
strQueSearch = strQueSearch + " and t_Que.QueCompleted=1 "
ElseIf Completed = 2 Then
'No
strQueSearch = strQueSearch + " and t_Que.QueCompleted=0 "
End If

If Priority > 0 Then
If PriorityMod = 0 Then
'>
strQueSearch = strQueSearch + " and t_Que.QuePriority >@QuePriority "
ElseIf PriorityMod = 1 Then
'<
strQueSearch = strQueSearch + " and t_Que.QuePriority <@QuePriority "
ElseIf PriorityMod = 2 Then
'=
strQueSearch = strQueSearch + " and t_Que.QuePriority =@QuePriority "
End If
End If
If RemainingCalls > 0 Then
If RemainingCallsMod = 0 Then
'>
strQueSearch = strQueSearch + " and t_Que.QueQuantity >@QueQuantity "
ElseIf RemainingCallsMod = 1 Then
'<
strQueSearch = strQueSearch + " and t_Que.QueQuantity <@QueQuantity "
ElseIf RemainingCallsMod = 2 Then
'=
strQueSearch = strQueSearch + " and t_Que.QueQuantity =@QueQuantity "
End If
End If

If TotalCalls > 0 Then
If TotalCallsMod = 0 Then
'>
strQueSearch = strQueSearch + " and t_Que.QueTotal >@QueTotal "
ElseIf TotalCallsMod = 1 Then
'<
strQueSearch = strQueSearch + " and t_Que.QueTotal <@QueTotal "
ElseIf TotalCallsMod = 2 Then
'=
strQueSearch = strQueSearch + " and t_Que.QueTotal =@QueTotal "
End If
End If

If Bonus > 1 Then
strQueSearch = strQueSearch + " and t_Que.BonusID =@BonusID "
End If

If Keyword1 <> "" Then
strQueSearch = strQueSearch + " and t_Que.QueNotes like '%'+@Keyword1+'%' "
End If
If Keyword2 <> "" Then
strQueSearch = strQueSearch + " and t_Que.QueNotes like '%'+@Keyword2+'%' "
End If
If Keyword3 <> "" Then
strQueSearch = strQueSearch + " and t_Que.QueNotes like '%'+@Keyword3+'%' "
End If
If Keyword4 <> "" Then
strQueSearch = strQueSearch + " and t_Que.QueNotes like '%'+@Keyword4+'%' "
End If
If Keyword5 <> "" Then
strQueSearch = strQueSearch + " and t_Que.QueNotes like '%'+@Keyword5+'%' "
End If


'makes statement into sqlcommand
C.daQueSearch.SelectCommand.CommandText = strQueSearch



'var declaration
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@BatchID", SqlDbType.VarChar, 12))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@Manager", SqlDbType.Int))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@RepID", SqlDbType.Int))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@QueDate", SqlDbType.VarChar, 20)) '<--- This is what,when i change to datetime, says it cant convert
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@QueStartDate", SqlDbType.VarChar, 20))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@QueDateComplete", SqlDbType.VarChar, 20))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@QuePriority", SqlDbType.Int))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@QueQuantity", SqlDbType.BigInt))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@QueTotal", SqlDbType.BigInt))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@BonusID", SqlDbType.SmallInt))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@Keyword1", SqlDbType.VarChar, 50))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@Keyword2", SqlDbType.VarChar, 50))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@Keyword3", SqlDbType.VarChar, 50))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@Keyword4", SqlDbType.VarChar, 50))
C.daQueSearch.SelectCommand.Parameters.Add(New SqlParameter("@Keyword5", SqlDbType.VarChar, 50))

'data entry
C.daQueSearch.SelectCommand.Parameters("@BatchID").Value = BatchID
C.daQueSearch.SelectCommand.Parameters("@Manager").Value = CreatedBy
C.daQueSearch.SelectCommand.Parameters("@RepID").Value = CreatedFor
C.daQueSearch.SelectCommand.Parameters("@QueDate").Value = DateCreated
C.daQueSearch.SelectCommand.Parameters("@QueStartDate").Value = DateStarted
C.daQueSearch.SelectCommand.Parameters("@QueDateComplete").Value = DateCompleted
C.daQueSearch.SelectCommand.Parameters("@QuePriority").Value = Priority
C.daQueSearch.SelectCommand.Parameters("@QueQuantity").Value = RemainingCalls
C.daQueSearch.SelectCommand.Parameters("@QueTotal").Value = TotalCalls
C.daQueSearch.SelectCommand.Parameters("@BonusID").Value = Bonus
C.daQueSearch.SelectCommand.Parameters("@Keyword1").Value = Keyword1
C.daQueSearch.SelectCommand.Parameters("@Keyword2").Value = Keyword2
C.daQueSearch.SelectCommand.Parameters("@Keyword3").Value = Keyword3
C.daQueSearch.SelectCommand.Parameters("@Keyword4").Value = Keyword4
C.daQueSearch.SelectCommand.Parameters("@Keyword5").Value = Keyword5


Try
C.ndConnection.Open()
C.daQueSearch.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
lblMainError1.Text = err("dbDGQSSearch " + ex.Source, ex.Message, CurUsr)
lblMainError1.Visible = True
Finally
C.ndConnection.Close()
End Try

FillQSDG()' this fills the datagrid


End Function

View 8 Replies View Related

Convert Decimal To String Is Without Rounding Up

Jul 27, 2004

Hello I'm trying to write a SQL Statement along the lines of....

SELECT stringField + ' : ' + STR(decimalField) AS myField FROM tablename WHERE myCondition = myValue

Where stringField is a String field and decimalField is a Decimal Field in my Table.
In this statement it converts the decimal field to a string value so that it doesn't throw a conversion error but unfortunatly it seems to round up the value to an integer value and cuts off all my decimal places.

How can I get it to keep the Decimal Places?

View 5 Replies View Related

Convert Date And Time To String?

Apr 16, 2004

Hi,

Can anyone tell me how to convert date and time to string.

I got one field inside my database which contain data like below:

4/16/2004 10:19:01 AM

if i wan to call out a record which have to refer to the data above

Select *
From table_A
where field_date= ???????

what to fill in the ??????

Thanx

View 3 Replies View Related

T-SQL (SS2K8) :: Convert String To Date?

Sep 5, 2014

I'm importing dates into a table with Bulk insert

SET DATEFORMAT DMY

it works with dates e.g. "14/01/2009"

However sometimes I get dates in the format

"Fri 14/01/2009"

What is the best way to convert these.

I can only think of putting them in a staging table with all date fields as varchars Then updating these varchar fields

LTRIM(REPLACE(dtField, 'Mon', ''))
LTRIM(REPLACE(dtField, 'Tues', ''))

View 9 Replies View Related







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