Continuation Of Long SQL Statement Syntax

Jul 23, 2005

Hi All -

I am updating four values. What is the proper syntax to have the
following 4 update statements as one statement?

set objRec = objDB.Execute("Update orientform set session = '" &
strSession & "' where id = '" & strid & "'")
set objRec = objDB.Execute("Update orientform set fname = '" & strfname
& "' where id = '" & strid & "'")
set objRec = objDB.Execute("Update orientform set gender = '" &
strgender & "' where id = '" & strid & "'")
set objRec = objDB.Execute("Update orientform set lname = '" & strlname
& "' where id = '" & strid & "'")

Thanks,

Joey

View 1 Replies


ADVERTISEMENT

Matrix Header Labels (continuation)

Oct 10, 2007



I addressed this situation in another thread, but since the thread had not been updated for some time I felt a new thread may have been warranted to included uptodate information and requests for further updates.

I will refresh the topic's primary issue:

When using a matrix, a developer wanted to provide column headers atop the columns to help users distinquish between multiple columns of the same relative data type(columns of digits, etc.)

The space in the upper left corner of the matrix will create a void that cannot be broken down or divided so that a column header label can be applied. It's either one label for the whole void or nothing at all.












VOID
Upper Group Column

Sub Group Column

Row Column 1
Row Column 2
Row Column 3
Row Column 4
Data

A poster suggested placing a rectangle inside the voided area above.











Rectangle
Upper Group Column

Sub Group Column

Row Column 1
Row Column 2
Row Column 3
Row Column 4
Data

Then placing a series of textboxes within the rectangle area aligned to the width of the row columns











Rectangle
Upper Group Column

rectangle txtbox
rectangle txtbox
rectangle txtbox
rectangle txtbox
Sub Group Column

Row Column 1
Row Column 2
Row Column 3
Row Column 4
Data

The problem is that when the report is run and rendered the rectangle txboxes are no longer aligned at the bottom. Even though the text within the textboxes is set to the bottom.
Instead the rendered version appears like this.











rectangle txtbox
rectangle txtbox
rectangle txtbox
rectangle txtbox
Upper Group Column





Sub Group Column

Row Column 1
Row Column 2
Row Column 3
Row Column 4
Data

Thus rather than having the labels inside the rectangle textboxes aligned at the bottom so that they appear more in-line with their assigned columns, they are automatically top-justified and this makes the labels look awkward.


So does anyone have any suggestions on how I can get the rectangle textboxes to be aligned adjacent to the tops of the row columns so that their labels appear in-line with their appropriate columns?

Thanks in advance.


View 1 Replies View Related

Continuation Of Emailing An Excel File

Sep 12, 2007

Hi Rafael,

I need to create a new excel file daily and then need to mail it.
The problem iam facing is that ,when i schedule a job the task that dumps data into excel(Dataflow task ) gives a validation error.Everytime i need to manually link the sheets of the excel to the corresponding tables.
Any idea why this is happening?So iam unable to schedule as a job...

Thanks,
Vani.

View 3 Replies View Related

How Long Is A SQL Statement Allowed To Be?

Jul 23, 2005

I am trying to make the following SQL statement, but there seems to a limiton how long a statement can be:INSERT INTO CUSTOMER (forename, surname, company_name, title, addressA,addressB, postal_number, city, country, home_phone, mobile_phone,work_phone, fax, email, sale_procentage, bank, account_number,creation_initials, creation_date, creation_reason) values ("test", "test","test", etc...);But I can only enter this much text:INSERT INTO CUSTOMER (forename, surname, company_name, title, addressA,addressB, postal_number, city, country, home_phone, mobile_phone,work_phone, fax, email, sale_procentage, bank, account_number,creation_initials, creation_date, creation_reason) vaIs there some upper limit? And how do I make a long SQL statement like this?JS

View 1 Replies View Related

Very Very Long SELECT Statement

Aug 17, 2007

I have SELECT statement that is several thousands of characters long - i'm declaring many tables, columns, and I have many aliases to deal with as well. Is there any way I can break it up into multiple lines? The only two things I could think of were using " + " . . . " + " . . . " or simply doing nothing and just dividing it into separate the lines. By the way, is there a limit to how long a SQL statement can be. I have been finding different answers when searching online.

View 5 Replies View Related

Taking Too Long Time For Insert Statement

Sep 19, 2007

Hi All,

Scenario:

There are two applications running on different server say ServerA and ServerB. Both applications are using same database server SQL Server 2005 say ServerB. Called the application as ApplicationA and ApplicationB with respect to Server names

It means for ServerA the database is remote and for ServerB, database is local.

Both the applications are Java application and using datasource to connect to the database. The driver used are SQL Server 2000 driver (which includes 3 jars). This can be a question that why 2000 driver is used for 2005. The reason is, application on ServerA is getting error while using SQL Server 2005 as Driver not proper.

Problem Area:

When ApplicationB (local to database) is doing some DB operations (which includes select and then batch insert), ApplicationA (remote) is trying to insert a record which is taking too long time (around 40 sec.). This is causing timed out in ApplicationA.

ApplicationA is inserting the data into the same table from where ApplicationB is selecting the data.

Any help????

Cheers
Nitin

View 2 Replies View Related

Two Problems In My Long And Complicated Select Statement!

Jan 3, 2008

Hello..
The first problem:
I have 2 tables in MS SQL database: topicstbl and txtfilestbl. And every one have column topicID.
And in both I have fulltext column I want to search in it; but in the first one I want to search in the fulltext column (topicflds) and also in normal columns (topicname and topicsn)
I need to search in these tables and get the (topicID) column as result by 1 table without repeated results.
I tried this code:
SELECT topicID, KEY_TBL.RANK FROM (SELECT topicID, 255 as RANK FROM topicstbl WHERE topicname like '%search word%' or topicsn like '%search word%') AS KEY_TBL
UNION
SELECT topicID, KEY_TBL.RANK FROM topicstbl AS topicstbl INNER JOIN CONTAINSTABLE(topicstbl, topicflds, 'search NEAR word') AS KEY_TBL ON topicstbl.topicID = KEY_TBL.[KEY]
UNION
SELECT topicID, KEY_TBL.RANK FROM txtfilestbl AS txtfilestbl INNER JOIN CONTAINSTABLE(txtfilestbl, txtfile, 'search NEAR word') AS KEY_TBL ON txtfilestbl.txtfileID = KEY_TBL.[KEY] ORDER BY KEY_TBL.RANK DESC

But the problem is the result table has repeated records (same topicID, different Rank Value).
Also I used "SELECT DISTINCT" but same problem.
The second problem:
I want to merge the previous code with ROW_NUMBER code to get results between x and y.
Like this code:
WITH OrderedOrders AS (SELECT *, ROW_NUMBER()
OVER (order by topicID DESC) as RowNumber
FROM topicstbl)

SELECT * FROM OrderedOrders
WHERE RowNumber between 1 and 50
But without change the first order.

Now how to do all these??!

View 6 Replies View Related

Select Statement In Sql Server 2000 Is Taking Too Long??

Jul 20, 2005

Hi All,I am facing problem in MS SQL Server 2000. It is behaving slow forselect statements. It is even slower than MS ACCESS. For example, if iuse"Select count(*) from tbl;". i get the results after long time ifthere is more than 100k rows. What might be the possible reasons forthis??ThanksHoque

View 1 Replies View Related

If STATEMENT Within Select Statement Syntax

May 15, 2008

Hi,

I am a newbie to this site and hope someone can help....

I have a select statement which I would like to create an extra column and put an if statement in it.... Current syntax is:

if(TL_flag= '1', "yes") as [Trial Leave]

it is coming up with an error.... I can use Select case but I should not need to as this should work?

Any ideas?

View 2 Replies View Related

SQL Server 2008 :: Store Long Values To Be Used In (IN) Statement In Separate Table?

Jul 14, 2015

I have several reports that are looking for a code within a certain set of codes or ranges. The specific list of codes to be including is determined by the end user. Currently my "IN" statement can be a hundred lines, listing several ranges, lists of specific codes, etc. I am constantly getting asked what codes does it include, is this code included, etc. Sometimes they'll give me a printed 10 page list of codes and want me to compare to what I have included in the report. Not ideal in the slightest.

What I'd like to do is have a table or a file of some kind somewhere where the end user can view the codes contained, add new ones, and delete ones they no longer want. Then I'd like to be able to just reference that file in my IN statement. Leaving the responsibility of listing the correct codes on them.

View 9 Replies View Related

What's The Right Syntax Of This Sql Statement?

Jan 23, 2008

Hi,
I created a sqldatasource (sql server) and a gridview.In the aspx file, i can see the selectcommand:
SelectCommand="select email from mytable"
Now, i want to modify something in the selectcommand produced in the aspx file, in order to get the emails in clickable mode. I knwow i have to add a string like:
<a hef="mailto:mailaddress">mailadress</a>
So i tried this:
SelectCommand="select '<a href="mailto:'+ email +'">' , email + '</a>' from email
But this gives the error: "tag is not well formed".The problem is the " around mailto:
Thanks
Cl.

View 4 Replies View Related

Sql Syntax Statement

May 23, 2008

Here is an sql query but it keeps giving me an error of   (Incorrect syntax near keywork ON)
here is the sql, don't get why this doe not work when I have done it this way multiple times.
select DISTINCT c.strSSN, p.sidstrNAME_IND,
p.sidstrGR_ABBR_CODE, p.sidstrSSN_SM, p.sidstrST_ADDR, p.sidstrADDR_CITY, p.sidstrSTATES_US, p.sidstrZIP_CODE, p.sidstrPAY_GR, p.sidstrMARTL_STAT,
p.sidstrNBR_EXEMPT, p.sidstrST_TAX_CODE, u.lsdbstrPHONE_NBR_HOME, case when sidstrTech_SVC_Code in ('M', 'R', 'S', 'T', 'U', 'Z') then
case when sidstrACT_STAT_PROG in ('5', 'A', 'E', 'F', 'N', 'R', 'S', 'T') then 'AGR' else 'Tech' end else 'M-Day' end
as status from tblAssignedPersonnel as c on ap.strssn = p.sidstrSSN_SM Inner Join
cms.dbo.tblLSDB as u on u.lsdbstrSSN_SM = c.strSSN inner joincms.dbo.tblSidpers as p on ap.strSSN = p.sidstrSSN_SM where intUICID = (select intUICID from tblUIC
where strUIC = '2' and intTaskForceID = '1') order by p.sidstrNAME_IND
 

View 3 Replies View Related

Syntax For IF-THEN In SQL Select Statement

Sep 3, 2007

I need to use IF-THEN in a SQL Select statement.  Using Google
I have found a couple of obscure references to this but nothing that I
can use.  Tried various combinations without luck.  Can
anyone point me to a good resource or supply a simple example of proper
syntax?  Thanks in advance for any help provided.

View 2 Replies View Related

Incorrect Syntax Near ','. Sql Statement

Dec 4, 2007

 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString2"].ToString());        SqlCommand myCommand = new SqlCommand("SELECT (Deadline, Description, Headline, AddressField, OrganizationField, NameField, FileField, EmailField, CommentField) FROM RegistrationFormDB_Info WHERE (UserName = @UserName AND TournamentName = @TournamentName)", myConnection);        SqlParameter myParam = new SqlParameter();        myParam.ParameterName = "@UserName";        myParam.Value = User.Identity.Name;        myCommand.Parameters.Add(myParam);        myParam = new SqlParameter();        myParam.ParameterName = "@TournamentName";        myParam.Value = Request.QueryString["TournamentName"];        myCommand.Parameters.Add(myParam);        myConnection.Open();        SqlDataReader myReader = myCommand.ExecuteReader();   <======================  I continue to get this error and I can't figure out the problem!  Anything helps.  Thank you very much. 

View 1 Replies View Related

SQL Syntax With For Select Like Statement

Dec 6, 2007

Hello,
 
I have the following statement that I am trying to convert to a "like" statement in a SqlDataSource for a web application.  I can't seem to get the syntax correct.  Would someone be able to assist with this?  Thanks!
SELECT * FROM [Employees] WHERE ([LName] = @LName) ORDER BY [LName], [FName]
Something like below.
SELECT * FROM [Employees] WHERE ([LName] LIKE '@LName%') ORDER BY [LName], [FName]

View 3 Replies View Related

SQL Statement Syntax Error?

Apr 22, 2008

SELECT DISTINCT CONVERT (nvarchar , tblSubject.Subject, 108) AS SubjectTime, CONVERT (nvarchar(11), tblSubject.Subject, 100) AS Date FROM tblLooker,tblSubject,tblStop WHERE NOT (SELECT DISTINCT CONVERT (nvarchar , tblSubject.Subject, 108) AS SubjectTime, CONVERT (nvarchar(11), tblSubject.Subject, 100) AS Date FROM tblSubject, tblLooker, tblStop WHERE tblSubject.Subject > tblLooker.Looker AND tblSubject.Subject < tblStop.Stop AND tblLooker.id = tblStop.id) Msg 170, Level 15, State 1, Line 5Line 5: Incorrect syntax near ')'. Can anyone tell me why this is not working? Thanks   

View 1 Replies View Related

LIKE Syntax In A SELECT Statement

May 19, 2008

What is the syntax for making a query using like, the below is my code
 <asp:SqlDataSource ID="Search" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
ProviderName="<%$ ConnectionStrings:DatabaseConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Products]WHERE category LIKE %@category%">
 
<SelectParameters>
<asp:QueryStringParameter Name="category"
QueryStringField="category" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
 Its giving a syntax error but I dont know how to change it.
Please advise, thanks!

View 5 Replies View Related

EFFECTIVE SQL STATEMENT SYNTAX

Oct 3, 2001

Hi all,

I am a java developer having little bit knowledge in sql statements.
can any body guide me what is the effective way of using sql statement
to achieve the following goal.

here is the requirement.

1. There are 2 tables A & B.

2.The table 'B' may or maynot have an equivalent entry for the primary
key of table a.

3. select column1 (of A), column 2(of B) from table a and b.

4. now column2 should give a value, if there is a corresponding
entry in table b.other wise null.

5. at any time there may be 0 to 1 record in table b for the primary
of table a.


thanks in advance
krishna

View 1 Replies View Related

CASE Statement Syntax

Jun 21, 2000

Can someone tell me what is wrong with my syntax? I am getting several errors:

Incorrect syntax near keyword 'CASE'
Incorrect syntax near keyword 'WHEN'


Incorrect syntax near '@Tablename'


CREATE PROCEDURE al_readcampsignup


@User_ID int,


@Pagenumber smallint,


@Tablename varchar(10)


AS


CASE @Mypagenumber WHEN 1 THEN SELECT Blah FROM tempcampsignup WHERE Camp_ID = @User_ID WHEN 2 THEN SELECT Blah FROM @Tablename WHERE Camp_ID = @User_ID WHEN 3 THEN SELECT Blah FROM @Tablename WHERE Camp_ID = @User_ID END

Thanks

View 1 Replies View Related

Syntax To Join With And Statement

Jan 17, 2014

I inherited a query and I am getting an error of Unsupported literal in join in the INNER JOIN FRDM.dbo.MEMBER_SUBSC FRDM_dbo_MEMBER_SUBSC2

ON (frdm.dbo.CLAIM_HEADER_WITH_VOIDS_VIEW.SBSB_CK = FRDM_dbo_MEMBER_SUBSC2.SBSB_CK AND FRDM_dbo_MEMBER_SUBSC2.MEME_SFX
= '00')statement. Specifically the AND FRDM_dbo_MEMBER_SUBSC2.MEME_SFX
= '00')part.
SELECT frdm.dbo.CLAIM_HEADER_WITH_VOIDS_VIEW.GRGR_ID AS 'group number'

[code]....

View 1 Replies View Related

SYNTAX Help, Correct Way To Use LIKE In Statement

Feb 27, 2007

Hi, I'm new to SQL and was wondering if there was an easier way to filter data.

I have two tables -

The first table called Names of Companies has a column named: NAMES

NAMES
XYZ Company
ABC Limited Liability Company
ZZZ Corporation
KKK Inc.
ABC Inc.

The second table called Keywords has a column named: WORDS

WORDS
Company
Limited


I want to search for all NAMES that contain the WORDS in some form

The results should be:

NAMES
XYZ Company
ABC Limited Liability Company

Technically, I can get the results I want by manually typing into the SQL statement all the words that appear in the WORDS column.

SELECT *
FROM [Names of Companies]
WHERE [Names of Companies].Names Like "*Company*" Or ([Names of Companies].Names) Like "*limited*"));

But is there a way that I reference the table Keyword instead of typing into the query statement all the words that appear in the column WORD? I have a lot of words to search for.

Can anyone recommend a better way to do this?

Thanks for all your help!

View 8 Replies View Related

Incorrect Syntax Using IF Statement

Apr 6, 2006

Hi,I'm new to SQL Server Programming, I work with ASP a lot, but latelyI've been trying to create Stored Procedures, etc. I'm having aproblem writing a simple IF statement.. I don't seem to understand whyit's giving me this error. I've search around on Google Groups, but Istill don't get it.=================USE msdbIF NOT EXISTS (SELECT * FROM sysjobs WHERE name = 'Scheduled Nightfax')END=================My error is:Server: Msg 156, Level 15, State 1, Line 5Incorrect syntax near the keyword 'END'.Thanks for any help.

View 2 Replies View Related

If Statement ... Syntax Error

Apr 9, 2008

hi, i've got this code





Code Snippet

go

create proc dbo.sp_GetFilterOrgIDs(@ID int)

as

select distinct


O.ID

from


Organisations O

if (@ID != 0)

begin


where O.ID = @ID
end






and am getting


Incorrect syntax near the keyword 'where'.

any idea why??

View 6 Replies View Related

IIF Statement Has Syntax Error...please Help...

May 20, 2008

I am trying to figure out the syntax for the following:

=iif(fields!ExtTripCount.value = 1,sum(Fields!ExtTripCount.value),0) / (count(fields!SvcCallNumber.value))* 100

I am trying to take all the trips that equal a one and divide them by the total number of service calls and then multiple them by 100 to get the percentage.

I am receiving the following errror: "The value expression refers to the field 'SvcCallNumber'. Report item expressions can only refer to fields within the current dta set scope or, if inside an aggregate, the specified data set scope...

View 3 Replies View Related

Syntax Error On Insert Statement

Jan 11, 2007

Ok, the following four lines are four lines of code that I'm running, I'll post the code and then explain my issue:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCommand = New SQLCommand("INSERT INTO Bulk (Bulk_Run, Bulk_Totes, Bulk_Drums, Bulk_Boxes, Bulk_Bags, Bulk_Bins, Bulk_Crates) VALUES (" &amp; RunList(x,0) &amp; ", " &amp; Totes &amp; ", " &amp; Drums &amp; ", " &amp; Boxes &amp; ", " &amp; Bags &amp; ", " &amp; Bins &amp; ", " &amp; Crates &amp; ")", Connection)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCommand.ExecuteNonQuery()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCommand = New SQLCommand("INSERT INTO Presort (Presort_Run, Presort_Totes, Presort_Drums, Presort_Boxes, Presort_Bags, Presort_Bins, Presort_Crates) VALUES (" &amp; RunList(x,0) &amp; ", " &amp; Totes &amp; ", " &amp; Drums &amp; ", " &amp; Boxes &amp; ", " &amp; Bags &amp; ", " &amp; Bins &amp; ", " &amp; Crates &amp; ")", Connection)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCommand.ExecuteNonQuery()
The two tables (Bulk & Presort) are <b>exactly</b> the same.  This includes columns, primary keys, IDs, and even permissions.  If I run the last two liens (the INSERT INTO Presort) then it works fine without error.  But whenever I run the first two lines (the INSERT INTO Bulk) I get the following error:
Incorrect syntax near the keyword 'Bulk'.
Anyone have any ideas, thanks

View 2 Replies View Related

Syntax Error In UPDATE Statement.

May 2, 2008

Hi forum, im converting some code and have an issue with th following code!!! many thanks for good advice, Paul
Line 55:     SQLa = "UPDATE counted SET " & y & " = " & intClick & ", total = " & intTotal & " WHERE ID = " & RSpc.Fields("pc").ValueLine 56:     Conn.Execute(SQLa)
System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement.
Dim SQLa As String 

View 8 Replies View Related

Syntax Error In UPDATE Statement.

Apr 13, 2004

I have place a lblmessage.text = ex.Message to trace what happen and it show me a syntax error in update happen. I don't know whats wrong with my syntax. Can someone help me on this?

<%@ Page Language = "vb" Debug="true" %>
<%@ import namespace= "system.data" %>
<%@ import namespace= "system.data.oledb" %>
<script runat="server">

'set up connection
dim conn as new oledbconnection _
("provider = microsoft.jet.oledb.4.0;" & _
"data source = c:aspnetdataanking.mdb")




sub page_load(sender as object, e as eventargs)
if not page.ispostback then
filldatagrid()
end if
end sub




sub submit (sender as object, e as eventargs)
'insert new data
dim i,j as integer
dim params(7) as string
dim strtext as string
dim blngo as boolean = true

j = 0

for i = 0 to addpanel.controls.count -1
if addpanel.controls(i).gettype is _
gettype (textbox) then
strtext = ctype(addpanel.controls(i), _
textbox).text
if strtext <> "" then
params(j) = strtext
else
blngo = false
lblmessage.text = lblmessage.text & _
"you forgot to enter a value for " & _
addpanel.controls (i).id & "<p>"
lblmessage.style ("forecolor")= "red"
end if
j=j+1
end if
next

if not blngo then
exit sub
end if

dim strsql as string = "INSERT INTO tblusers " & _
"(firstname, lastname, address, city, state, " & _
"zip, phone) values (" & _
"'" & params(0) & "'," & _
"'" & params(1) & "'," & _
"'" & params(2) & "'," & _
"'" & params(3) & "'," & _
"'" & params(4) & "'," & _
"'" & params(5) & "'," & _
"'" & params(6) & "')"

executestatement(strsql)
filldatagrid()
end sub




sub dgdata_edit (sender as object, e as datagridcommandeventargs)
filldatagrid(e.item.itemindex)
end sub




sub dgdata_delete (sender as object, e as datagridcommandeventargs)
dim strsql as string = "DELETE FROM tblusers " & _
"WHERE userid = " & e.item.itemindex + 1

executestatement(strsql)
filldatagrid()
end sub




sub dgdata_update (sender as object, e as datagridcommandeventargs)
if updatedatastore(e) then
filldatagrid(-1)
end if
end sub



sub dgdata_cancel (sender as object, e as datagridcommandeventargs)
filldatagrid(-1)
end sub



sub dgdata_pageindexchanged (sender as object, e as datagridpagechangedeventargs)
dgdata.databind()
end sub



function updatedatastore (e as datagridcommandeventargs) as boolean
dim i,j as integer
dim params(7) as string
dim strtext as string
dim blngo as boolean = true

j = 0

for i =1 to e.item.cells.count - 3
strtext = ctype(e.item.cells(i).controls(0), _
textbox).text
if strtext <> "" then
params(j) = strtext
blngo = true
j= j+1
else
blngo = false
lblmessage.text = lblmessage.text & _
"you forgot to enter a value<p>"
end if
next

if not blngo then
return false
exit function
end if

dim strsql as string = "update tblusers SET " & _
"Firstname.value = '" & params(0) & "'," & _
"lastname.value = '" & params(1) & "'," & _
"address.value = '" & params(2) & "'," & _
"city.value = '" & params(3) & "'," & _
"state.value = '" & params(4) & "'," & _
"zip.value = '" & params(5) & "'," & _
"phone.value = '" & params(6) & "'," & _
" WHERE Userid = " & ctype(e.item.cells(0). _
controls(1), label).text

executestatement (strsql)
return blngo
end function

sub filldatagrid (optional editindex as integer = -1)
' open connection
dim objcmd as new oledbcommand _
("select * from tblusers", conn)
dim objreader as oledbdatareader

try
objcmd.connection.open ()
objreader = objcmd.executereader()
catch ex as exception
lblmessage.text = "error retrieving from the " & _
"database."
end try

dgdata.datasource = objreader
if not editindex.equals(nothing) then
dgdata.edititemindex = editindex
end if

dgdata.databind()
objreader.close
objcmd.connection.close()

end sub

function executestatement (strsql)
dim objcmd as new oledbcommand(strsql, conn)

try
objcmd.connection.open()
objcmd.executenonquery()
catch ex as exception
lblmessage.text = ex.message
end try

objcmd.connection.close()
end function
</script>

<html><body>
<asp:label id= "lblmessage" runat ="server" />
<form runat= "server">
<asp:datagrid id = "dgdata" runat ="server"
bordercolor = "black"
gridlines="vertical"
cellpadding ="4"
cellspacing="0"
width = "100%"
autogeneratecolumns = "False"
ondeletecommand = "dgdata_delete"
oneditcommand = "dgdata_edit"
oncancelcommand = "dgdata_cancel"
onupdatecommand = "dgdata_update"
onpageindexchanged= "dgdata_pageindexchanged"
font-names = "arial"
font-size="8pt"
showfooter = "true"
headerstyle-backcolor= "#cccc99"
footerstyle-backcolor= "#cccc99"
itemstyle-backcolor= "#ffffff"
alternatingitemstyle-backcolor="#cccccc">

<columns>
<asp:templatecolumn headertext="id">
<itemtemplate>
<asp:label id = "name" runat = "server"
text = '<%# container.dataitem("userid")%>' />
</itemtemplate>
</asp:templatecolumn>

<asp:boundcolumn headertext = "firstname"
datafield = "firstname" />

<asp:boundcolumn headertext = "lastname"
datafield = "lastname" />

<asp:boundcolumn headertext = "address"
datafield = "address" />

<asp:boundcolumn headertext = "city"
datafield = "city" />

<asp:boundcolumn headertext = "state"
datafield = "state" />

<asp:boundcolumn headertext ="zip"
datafield = "zip" />

<asp:boundcolumn headertext ="phone"
datafield = "phone" />

<asp:editcommandcolumn
edittext="Edit"
canceltext="cancel"
updatetext="update"
headertext = "edit"/>

<asp:buttoncolumn headertext = "delete?" text = "X"
commandname = "delete"
buttontype = "pushbutton" />

</columns>
</asp:datagrid><p>

<asp:panel id= "addpanel" runat = "server">
<table>
<tr>
<td width ="100" valign = "top">
first and last name:
</td>
<td width ="300" valign = "top">
<asp:textbox id= "tbfname" runat = "server"/>
<asp:textbox id= "tblname" runat = "server"/>
</td>
</tr>
<tr>
<td valign = "top">address:</td>
<td valign= "top">
<asp:textbox id= "tbaddress" runat = "server"/>
</td>
</tr>
<tr>
<td valign = "top">city, state, zip:</td>
<td valign= "top">
<asp:textbox id= "tbcity" runat = "server"/>
<asp:textbox id= "tbstate" runat = "server"/>
<asp:textbox id= "tbzip" runat = "server"
size=5 />
</td>
</tr>
<tr>
<td valign= "top">phone:</td>
<td valign= "top">
<asp:textbox id= "tbphone" runat = "server"
size = 11/><p>
</td>
</tr>
<tr>
<td colspan = "2" valign = "top" allign = "right">
<asp:button id = "btsubmit" runat ="server" text ="add"
onclick = "submit" />
</td>
</tr>
</table>
</asp:panel>
</form>
</body></html>

View 14 Replies View Related

Syntax Error On INSERT Statement

Dec 16, 2005

Here is my insert statement:  StringBuilder sb = new StringBuilder();            sb.Append("INSERT INTO patients_import_test ");        sb.Append("(Referral_Number,Referral_Date,FullName,Patient_ien,DOB,FMP,SSN_LastFour,Race_Id,PCM,Age) ");            sb.Append("VALUES(@rnum,@rdate,@fname,@patid,@birthDate,@fmp,@ssan,@race,@pcm,@age) ");            sb.Append("WHERE Referral_Number NOT IN ( SELECT Referral_Number FROM patients_import_test )");I'm getting an "Incorrect syntax near the keyword 'WHERE'".If I remove the WHERE clause the INSERT statement work fine.

View 3 Replies View Related

CASE Statement Syntax Problem

Jan 16, 2008

I am attempting to mask a user's SS# based on Users.DisplaySSN. I have gone over the code time and time again and can't find where the error is.

Error I'm getting:
Incorrect syntax near the keyword 'AS'.

Here's where the error lies:
CASE
(SELECT DisplaySSN FROM Users WHERE Users.UserID = @UserID)
WHEN False THEN
'xxx-xx-xxxx' + right(SocialSecurityNumber,0) AS SocialSecurityNumber
ELSE
vwEmp.SocialSecurityNumber
END

View 6 Replies View Related

Insert Into Statement Syntax Error

May 30, 2006

Hi,

I have a problem as shown below


Server Error in '/ys(Do Not Remove!!!)' Application.


Syntax error in INSERT INTO statement.

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.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:





Line 8: <Script runat="server">
Line 9: Private Sub InsertAuthorized(ByVal Source As Object, ByVal e As EventArgs)
Line 10: SqlDataSource1.Insert()
Line 11: End Sub ' InsertAuthorized
Line 12: </Script>
Source File: C:Documents and SettingsDream_AchieverDesktopys(Do Not Remove!!!)Authorizing.aspx Line: 10

Stack Trace:





[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +56
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +105
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +88
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +392
System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +410
System.Web.UI.WebControls.SqlDataSource.Insert() +13
ASP.authorizing_aspx.InsertAuthorized(Object Source, EventArgs e) in C:Documents and SettingsDream_AchieverDesktopys(Do Not Remove!!!)Authorizing.aspx:10
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919




And part of my program is as shown

<Script runat="server">

Private Sub InsertAuthorized(ByVal Source As Object, ByVal e As EventArgs)

SqlDataSource1.Insert()

End Sub ' InsertAuthorized

</Script>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DIP1ConnectionString %>" ProviderName="<%$ ConnectionStrings:DIP1ConnectionString.ProviderName %>"

InsertCommand="Insert Into Authorize (Army ID,Tag No,Vehicle ID,Vehicle Type,Prescribed Route,Start Time, End Time) VALUES (@ArmyID, @TagNo, @VehicleID, @VehicleType, @PrescribedRoute, @StartTime, @EndTime)">

<insertparameters>

<asp:formparameter name="ArmyID" formfield="ArmyID" />

<asp:formparameter name="TagNo" formfield="TagNo" />

<asp:formparameter name="VehicleID" formfield="VehicleID" />

<asp:formparameter name="VehicleType" formfield="VehicleType" />

<asp:formparameter name="PrescribedRoute" formfield="PrescribedRoute" />

<asp:formparameter name="StartTime" formfield="StartTime" />

<asp:formparameter name="EndTime" formfield="EndTime" />

</insertparameters>

</asp:SqlDataSource>



Anybody can help? thanks

View 1 Replies View Related

Transact SQL :: Getting Syntax Errors In Where Statement

Oct 9, 2015

I've created multiple select statement to pull in varies fields from a table and one of those fields is Fiscal_Year, however, after the select statement I'm adding a Where clause:

Where Fiscal_Year = '2013'

And I keep getting a syntax error??

View 3 Replies View Related

Syntax Error In INSERT INTO Statement.

Apr 7, 2008

Public DBString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Q:VoicenetRTS FolderRTS ChargesAccountscosting.mdb"
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Dim connstring As New OleDbConnection(DBString)
connstring.Open()
Dim searchstring As String = "SELECT * FROM Costings1"
Dim da As New OleDbDataAdapter(searchstring, connstring)
Dim DS As New DataSet()
Dim dt As DataTable = DS.Tables("Costings1")
da.FillSchema(DS, SchemaType.Source, "Costings1")
da.Fill(DS, "Costings1")
Dim cb As New OleDbCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand
da.UpdateCommand = cb.GetUpdateCommand
Dim dr As DataRow = DS.Tables("Costings1").NewRow
dr("Key") = TextBox1.Text
dr("CODE") = TextBox2.Text
dr("Element") = TextBox3.Text
etc...
DS.Tables("Costings1").Rows.Add(dr)
da.Update(DS, "Costings1") <<<<<<<<<<<Syntax error in INSERT INTO statement.

There are no spaces in the field names.

View 9 Replies View Related

Can You Please Correct My Syntax For If Statement In Stored Proc

Nov 23, 2004

I am using @strsql to construct the where condition for a select query.
Can you please correct my syntax.



DECLARE @strsql nvarchar(2000)


IF @ProgNO <> '' then
strsql = WHERE ProgNO = @ProgNO
end if



If @ProjNO <> '' then
if strsql <> '' then
strsql = strsql & " and ProjNO =@ProjNO
ELSE
strsql = wHERE ProjNO =@ProjNO
END IF
END IF



Thank you very much.

View 9 Replies View Related







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