hello sir,
goodevening....
iam working on vb6.0 and sql2005. -
"select max(centreid) from regionmaster where centreid like '" & intBranchPrefix & "%'", DBConnection, adOpenKeyset, adLockOptimistic
-
If rsMain.RecordCount > 0 Then
-
intID = Mid(rsMain(0), 3, 13)
-
End If
-
intCentreID = intBranchPrefix & (intID + 1)
-
i have to convert the above code command in sql storeprocedure
where i have to generate centreid with branchprefix(ex :99 or 11) which is supplied by the application.i.e , intBranchPrefix. i have to take that branchprefix in storeprocedure and generate the centre id....that is
centerid=branch prefix & (id+!)
plz help me ......
prem........
11 2713 Delerna 1,134
Recognized Expert Top Contributor -
create proc GenerateCentreID @intBranchPrefix int
-
as
-
declare @MaxCentreID int,@intID varchar(50)
-
set @MaxCentreID=(select convert(int,max(substring(centreid,3,13))
-
from regionmaster
-
where centreid like @intBranchPrefix%
-
)
-
-
set @intID=@intBranchPrefix*10000000000000 + @MaxCentreID+1
-
go
-
I think thats right, you might need to fix some syntax. I haven't tested it
Mr.Delerna..Goo dMorning..,
i have got what u wrote but when i executed the proceure ..the error cameIncorrect syntax near ) of select statement
Hi the proc is correct just one closing bracket is missing
(int,max(substr ing(centreid,3, 13)))
I hope u got the ans.
Delerna 1,134
Recognized Expert Top Contributor
what is the data type of the field centreid in table regionmaster?
I will mock up a table so I can test the code.
I am guessing it is string but I don't want to guess
Delerna 1,134
Recognized Expert Top Contributor
if it is a character type then -
create proc GenerateCentreID @intBranchPrefix varchar(20)
-
as
-
declare @MaxCentreID bigint,@intID varchar(20)
-
set @MaxCentreID=(select convert(bigint,max(substring(centreid,3,13)))
-
from regionmaster
-
where centreid like @intBranchPrefix+'%'
-
)
-
-
set @intID=@intBranchPrefix + convert(varchar(13),@MaxCentreID+1)
-
select @intID
-
-
go
-
the error you mention was due to there not being enough closing brackets in the select criteria of the query.
Also the parameter was not the correct type.
Also I forgot the + '%' in the where
NOTE:datatype of centerid is decimal(13,2) in table...
here came the error when i execute the given proc Argument data type decimal is invalid for argument 1 of substring function. Delerna 1,134
Recognized Expert Top Contributor
Then try converting centreid to character in the query.
The like opperator works with strings! -
create proc GenerateCentreID @intBranchPrefix varchar(20)
-
as
-
declare @MaxCentreID bigint,@intID varchar(20)
-
set @MaxCentreID=(select convert(bigint,max(substring(convert(varchar(20),centreid),3,13)))
-
from regionmaster
-
where convert(varchar(20),centreid) like @intBranchPrefix+'%'
-
)
-
-
set @intID=@intBranchPrefix + convert(varchar(20),@MaxCentreID+1)
-
select @intID
-
-
go
-
thanks Delerna...i got it..
hi delerna ...sorry for troubling u again...
when iam calling the store procedure from vb6 application in CmdSave_Click
it is giving Error:The Precision is invalid ...
iam not getting the exact thing/meaning...
so plz help me out...
here is the code: -
Private Sub SaveBranchProcedure()
-
-
Dim cmd As New ADODB.Command
-
Dim param1 As ADODB.Parameter
-
Dim pm As Integer
-
Dim i As Integer
-
-
Set cmd.ActiveConnection = DBConnection
-
-
cmd.CommandType = adCmdStoredProc
-
' cmd.CommandText = "sp_savebranchmaster"
-
cmd.CommandText = "sp_branchonly"
-
cmd.Parameters.Append cmd.CreateParameter("BranchPrefix", adNumeric, adParamInput, 13, intBranchPrefix)
-
' cmd.Parameters.Append cmd.CreateParameter("centreid", adNumeric, adParamOutput, intID)
-
cmd.Parameters.Append cmd.CreateParameter("centretype", adVarChar, adParamInput, 3, "SR")
-
cmd.Parameters.Append cmd.CreateParameter("centrename", adVarChar, adParamInput, 60, Val(TxtName))
-
cmd.Parameters.Append cmd.CreateParameter("code", adVarChar, adParamInput, 6, Val(TxtCode))
-
-
If CmbBusinessType.Text = "Booking" Then
-
cmd.Parameters.Append cmd.CreateParameter("BRANCH_BUSINESS_TYPE", adVarChar, adParamInput, 6, "BOOK")
-
-
ElseIf CmbBusinessType.Text = "Delivery" Then
-
cmd.Parameters.Append cmd.CreateParameter("BRANCH_BUSINESS_TYPE", adVarChar, adParamInput, 6, "DELI")
-
-
ElseIf CmbBusinessType.Text = "OTHER" Then '"Booking and Delivery"
-
cmd.Parameters.Append cmd.CreateParameter("BRANCH_BUSINESS_TYPE", adVarChar, adParamInput, 6, "BKDL")
-
-
ElseIf CmbBusinessType.Text = "Transhipment" Then
-
cmd.Parameters.Append cmd.CreateParameter("BRANCH_BUSINESS_TYPE", adVarChar, adParamInput, 6, "TRAN")
-
End If
-
-
cmd.Parameters.Append cmd.CreateParameter("levelno", adNumeric, adParamInput, 13, 0)
-
cmd.Parameters.Append cmd.CreateParameter("indexno", adNumeric, adParamInput, 13, 0)
-
cmd.Parameters.Append cmd.CreateParameter("groupno", adNumeric, adParamInput, 13, 0)
-
-
cmd.Parameters.Append cmd.CreateParameter("group_node_flag", adVarChar, adParamInput, 1, "A")
-
-
If Trim(TxtAddress) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("address", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("address", adVarChar, adParamInput, 50, Val(TxtAddress))
-
End If
-
-
If Trim(txtAdd1) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("address1", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("address1", adVarChar, adParamInput, 50, Val(txtAdd1))
-
End If
-
-
If Trim(txtAdd2) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("address2", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("address2", adVarChar, adParamInput, 50, Val(txtAdd2))
-
End If
-
-
If Trim(TxtPhone) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("phone", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("phone", adVarChar, adParamInput, 20, Val(TxtPhone))
-
End If
-
-
If Trim(TxtFax) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("fax", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("fax", adVarChar, adParamInput, 20, Val(TxtFax))
-
End If
-
-
If Trim(TxtEmail) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("email", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("email", adVarChar, adParamInput, 30, Val(TxtEmail))
-
End If
-
-
If Trim(TxtManager) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("manager", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("manager", adVarChar, adParamInput, 30, Val(TxtManager))
-
End If
-
-
If Trim(TxtMgrPhone) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("MANAGER_PHONE", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("MANAGER_PHONE", adVarChar, adParamInput, 20, Val(TxtMgrPhone))
-
End If
-
-
If Trim(TxtRemarks) = "" Then
-
cmd.Parameters.Append cmd.CreateParameter("REMARKS", adVarChar, adParamInput, 4, Null)
-
Else
-
cmd.Parameters.Append cmd.CreateParameter("REMARKS", adVarChar, adParamInput, 50, Val(TxtRemarks))
-
End If
-
-
cmd.Parameters.Append cmd.CreateParameter("mainparent", adNumeric, adParamInput, 13, 0) 'frmTreeMaster.sngMainParentKey
-
-
-
If ChkAcct.Value = 1 Then
-
cmd.Parameters.Append cmd.CreateParameter("acct_y_n", adVarChar, adParamInput, 1, "Y")
-
ElseIf ChkAcct.Value = 0 Then
-
cmd.Parameters.Append cmd.CreateParameter("acct_y_n", adVarChar, adParamInput, 1, "N")
-
End If
-
-
cmd.Parameters.Append cmd.CreateParameter("acct_branch", adVarChar, adParamInput, 20, vsgBranch.Text)
-
-
cmd.Parameters.Append cmd.CreateParameter("CREATED_BY", adNumeric, adParamInput, 13, g_UserData.UserID)
-
cmd.Parameters.Append cmd.CreateParameter("CREATED_DATE", adDate, adParamInput, 13, Format(g_LoginData.ServerDate, "DD-MMM-YY"))
-
cmd.Parameters.Append cmd.CreateParameter("delete_flag", adVarChar, adParamInput, 1, "N")
-
-
cmd.Execute
-
-
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mark A. Gibbs |
last post by:
I have a string conversion function that looks something like this
(apologies, but I cannot post the actual code):
whar_t char_to_wchar(char);
wstring to_wstring(const string& s)
{
wstring result(s.length(), '\0');
transform(s.begin(), s.end(), result.begin(), ptr_fun(char_to_wchar));
|
by: vertigo |
last post by:
Hello
I have strange problem, i have map<myclass1*,myclass2*,Compare>.
Code:
std::map<myclass1*,myclass2*,Compare> m=mymap;
std::map<myclass1*,myclass2*,Compare>::const_iterator ci;
printf("Elements: %d\n",m.size());
for(ci=m.begin();ci!=m.end();ci++){
printf("text\n");
}
|
by: Niyazi |
last post by:
Hi,
Me again. I want to create a SQL Server StoreProcedure and I want to access
it with ADO.NET. I am using VB.NET.
Creating StoreProcedure it was easy but my question is this.
I have table with 4 Column and 6 rows. In the Column 3 for all rows I have
to insert data. The data considt of the decimal value of Croiss Exchange and
6 my variable as:
|
by: Megan |
last post by:
quick summary: i'm having problems trying to group fields in a report
in order to calculate percentages. to calculate percentages, i'm
comparing the results from my grouped fields to the totals.
first, let me say that this is a really long post. i wasn't sure how
much information/ background to provide, so i thought more was better
than less. i tried to delineate certain areas so that it would be
easy to peruse my posting and find...
|
by: ward |
last post by:
Greetings.
Ok, I admit it, I bit off a bit more than I can chew.
I need to complete this "Generate Report" page for my employer and I'm
a little over my head. I could use some additional assistance. I say
additional because I've already had help which is greatly appreciated.
I do try to take the time and understand the provided script in hopes
on not having to trouble others on those. But here it goes...
| |
by: divya |
last post by:
Hi,
I have a table tblbwday with 2 fields Name and Birthday.I have written
this script for displaying evryday names of the people on that day.
<%
set objConn =server.createobject("ADODB.connection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjRSSel
sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
|
by: delif04031 |
last post by:
How to implements storeprocedure in PostgreSQL?
|
by: Yas |
last post by:
Hello, I have the following table with 4 columns....
firstname, lastname1, lastname2, EMAIL
Table has user names and email, I would like to generate a 5th column
called DisplayName.
The email Id is sometimes firstname.lastname1.lastname2@ and others
just firstname.lastname1@
I would like to generate the display name exactly like the email eg
|
by: mattehz |
last post by:
Hey there,
I am trying to upload old source files and came across these errors:
Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59
Notice: Undefined index: args in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92
Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |