choudhuryshouvi 33 Posting Pro

connection to the database using any technology whether it is DAO or RDO or ADO is possible. but it is true that by default vb6 cannot access .mdb database if it is created in some other format.but using service packs of vs may solve this problem.but if u use oracle or sql server databases there will be no problem at all.if u wish to use sp of vs u have to download it from microsoft.com

choudhuryshouvi 33 Posting Pro

hi, guys here is my question:-

I've created an application for opening text files. there i got two forms.one contains the textbox where the contents of the file will be displayed. there is a button.clicking this will move me to another form which is displaying modally.in the second form i choose file and click open to load the contents. there is another button "Close". now if i click this button the modal form should close and the control should move to the first form. now here is where i've stucked. can anyone tell me how to close a modal form wihout clicking the 'X' in form title bar.

Plz reply soon...

choudhuryshouvi 33 Posting Pro

thats because vb6 cannot directly access the databases in .mdb format other than the access95 version. u probably created the database using ms-access software. re-create the database using vb6's visual data manager. or u have to convert the database to an older version(access 97) using ms access's convert database utility.

choudhuryshouvi 33 Posting Pro

Thanks Debashis. I appreciate your reply. But I think I can explain this too. Hope you will recognize that.

n louislam 123 here are explanations. go through it......

the code in the form_load event simply adds some elements in the two combo boxes.three elements in combo1 and four elements in combo2.

now the code in command1_click event :-
whenver you select an item from both the combo boxes it will trap the index value for the selected item and add 1 to it,so that it can be looked as real numbers.hope u know that the combo box is a sort of array and the elements stored in an array is identified by its position no.,also known as index or subscript value and this index value always starts from 0.so,when you select the first item in the combo1 the event will trap its index as 0 and add 1 to it.so,it will become 0+1=1.same thing is for combo2 also.after this the code will just concate the two resulted index values and put an asterix between them.

hope the above explanation is enough for you to understand the logic behind this coding.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

no question of pain. i feel always happy when i do reply to someone. ok, lets begin.

to connect the database without using the VDM you need to create an ODBC DSN for the type of database you wish to connected to.

to create the DSN follow the step:-

1.goto control panel
2.select administrative tools
3.select datasources(odbc)
4.in the user dsn tab click on add
5.select the appropriate database driver.
for access it is "Microsoft Access Driver(.mdb)"
for sql server it is "Sql Server"
for oracle it is "Oracle in orahome<version no>"
where version no. is the version of oracle u have installed in ur server machine.lets say if u have oracle9i installed then the driver becomes "oracle in orahome9i",etc.

6.after selecting the driver click finish.
7.then in the dsn dialog box enter the dsn name in the provided textbox.this name can be anything.but make sure that it doesn't conflict with other dsn names.
8.you can also specify a description fror ur dsn there.this is an optional field.
9.then click the select button and locate the database file you wish to connect through the new dsn being created.click ok to save all settings and create the dsn.


in case of operation with vb6 do the following steps:-

1.open a new project
2.goto project->reference
3.check on microsoft activex dataobjects <version no> library.again this version no. depends on the version of …

choudhuryshouvi 33 Posting Pro

debasisdas,
i tried but it keeps giving me a syntax error.could something be missing?do u mean to write :
fac_type as

' " & fac_type & " '

and
booking_date as

' " & booking_date & " '

?

delete the trailing spaces from both side of the sql string. the correct syntax is:-

************for fac_type************
'" & fac_type & "'

************for booking_date************
'" & booking_date & "'

choudhuryshouvi 33 Posting Pro

see the sample project.
hope u will grab some idea from it.

before running the code add some records to the database.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

cmdsearch_click()
dim str as string
dim rs as new adodb.connection

str=inputbox("enter month","search")
if str<>"" then
rs.open "select * from <tablename> where month='" & str & "'"
if rs.recordcount>0 then
<display data>
else
msgbox "no record found"
endif
else
msgbox "input the month plz."
endif
end sub

choudhuryshouvi 33 Posting Pro

use this simple code.

Private Sub Command1_Click()
MsgBox Combo1.ListIndex + 1 & "*" & Combo2.ListIndex + 1
End Sub

Private Sub Form_Load()
With Combo1
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With
With Combo2
.AddItem "welcome"
.AddItem "to"
.AddItem "vb"
.AddItem "programming"
End With
End Sub

choudhuryshouvi 33 Posting Pro

hello. my problem is, after login username and password in one form, then a new form will be appear. how to create coding to insert username in a label at new form after login. i have tried this coding but still not appear. please help me. thanks.....


Public Sub loadInfo()
On Error Resume Next

checkConnection
strSql = "SELECT Username FROM Customer WHERE Psswd='" & strPsswd & "'"
rec1.Open strSql, con, adOpenStatic

lblUsername.Caption = rec1!Username

use this approach in ur coding :-

1. add a standard module in ur project from project->add module
2. in the module declare a public variable to store the username.the sysntax is :-
Public strUsername as String
3. then in the login form whenver you enter the username and password and hit the login button just pass the username to the above variable. the syntax is :-
strUsername=<your username>
4. after this you can access the value you just have passed to this variable from each and every form of your project. like in form2' label :-
LblUsrname.Caption=strUsername

Note : a public variable has a wide range than the usual standard variables which we declare using the 'Dim' keyword. Public variables are always declared by the 'Public' keyword and it has the effect to the entire project.

hope it will solve out ur probs.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

if the project will help you plz don't forget to mention it here. if u find any more problems just post it under the same thread or u can also mail me to choudhuryshouvik@gmail.com

choudhuryshouvi 33 Posting Pro

Hi, all here is my question:-

My application uses vb6 as front-end,ms sql server7.0 as back-end. i connect my apps with the rdbms using an odbc dsn connection. now i've created some reports for my apps using crystal report 8.5. the print is going well. now i want to export the contents of the report to some other formats namely to text and html.

now can anybody give me some idea on how to accomplish this?
if u guys post some some links here or resources that will be great.

waiting for ur valuable replies.
plz help me out............this is very urgent

regards
Shouvik

choudhuryshouvi 33 Posting Pro

hi all, i have problem creating queries in access.this is because i do not know how to call the value from a variable in vb into the query in access.
let say in vb i've created :

Public booking_date As Date
Public fac_type As Integer
.
.
.
.
booking_date = MonthView1.value
fac_type = Combo1.ItemData

i suppose to have a query done in access which i will call in vb

SELECT TF.time_id
FROM TF
WHERE (((TF.fac_id)="fac_type") AND ((TF.reserv_date)="booking_date"));

how do i accomplish this?please help!
thanx in advnce!

Hi, i've attached a sample program. download it. hope it will give you some idea.
regards
Shouvik

choudhuryshouvi 33 Posting Pro

Can someone out there provide me with notes or information on using data reports in Visual Basic 6.0

Hi, i've attached a sample project. download it. it will help you in creating and understanding data reports in vb6.

rajeshkhanna_in commented: Nice Work!! Keep it up. It was really Helpful and educative +1
choudhuryshouvi 33 Posting Pro

could not understand ur topic. will you plz explain it in detail? so that if u wish some one can help you.

choudhuryshouvi 33 Posting Pro

have u benefited from the sample code that i sent you?
do you have any more questions?
if u need any more help post it under the same thread or u can also mail me at choudhuryshouvik@gmail.com

choudhuryshouvi 33 Posting Pro

always use ITEM_CLICK event of the LISTVIEW control to extract information of a specific item from the database.check out the following sample code. it uses an access database and connect through DAO.

before running this code create an access database "resv.mdb" and four fields which are "resv_code","dest","date","time" & also insert some records there.

take one LISTVIEW control & name it as "lvdetails". add four colume headers as "Reservation Code","Destination","Journey Date","Journey Time".
four LABELS and name them "lblresv_code","lbldest","lbldate" and "lbltime" accordingly.

**********IN FORM_LOAD EVENT********
'extracting all records from the database and displaying those in a lv control.

Dim db As Database
Dim rs As Recordset
Dim li As ListItem

Set db = OpenDatabase(App.Path & "\resv.mdb")
Set rs = db.OpenRecordset("details", dbOpenTable)

If rs.RecordCount > 0 Then
rs.MoveFirst
While Not rs.EOF()
With lvdetails
Set li = .ListItems.Add(, , rs!resv_code)
li.SubItems(1) = rs!dest
li.SubItems(2) = Format(rs!Date, "MMM-dd-yyyy")
li.SubItems(3) = Format(rs!Time, "hh:mm:ss")
End With
rs.MoveNext
Wend
End If
Set rs = Nothing

********IN ITEM_CLICK EVENT OF THE LISTVIEW CONTROL************
'clicking an item will extract it's specific information fom the database and display those in the labels.

Private Sub lvdetails_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim db As Database
Dim rs As Recordset

Set db = OpenDatabase(App.Path & "\resv.mdb")
Set rs = db.OpenRecordset("select * from details where resv_code='" & Item.Text & "'")
If rs.RecordCount > 0 …

choudhuryshouvi 33 Posting Pro

look at the following code.hope it'll help you.
before running the code just create an access database named "np.mdb" under your project folder. just take a command button on a form.

'this is a global variable for storing how many no. of tables have been created so far

Dim tot_table As Variant

'creating a new table with two fields and naming as per it's position no.
Public Sub CreateNewTable()
Dim db As Database, td As TableDef, fd As Field

Set db = OpenDatabase(App.Path & "\np.mdb")

tot_table = GetSetting(App.Title, "Table", "Count")
If Trim(tot_table) = "" Then tot_table = 0 Else tot_table = Val(tot_table)
tot_table = tot_table + 1
Set td = db.CreateTableDef("Table" & tot_table)
Set fd = td.CreateField("Rec_ID", dbLong)
fd.Attributes = dbAutoIncrField
td.Fields.Append fd
Set fd = td.CreateField("Rec_Desc", dbText, (255))
td.Fields.Append fd
db.TableDefs.Append td
db.Close
SaveSetting App.Title, "Table", "Count", tot_table
End Sub

'extracting each data from the notepad file and transferring the same into the table just created
Public Sub DoNP2DB()
Dim db As Database
Dim rs As Recordset
Dim rec As Integer
Dim str As String

Set db = OpenDatabase(App.Path & "\np.mdb")
Set rs = db.OpenRecordset("Table" & tot_table, dbOpenTable)
If rs.RecordCount > 0 Then rs.MoveFirst

rec = 1

Open App.Path & "\DBRecord.txt" For Input As #1
Do While Not EOF(1)
Input #1, str
rs.AddNew
If rs.EditMode …

choudhuryshouvi 33 Posting Pro

can u approach to send a copy of ur program?
if yes then send it to choudhuryshouvik@gmail.com
i'll check and fix that.
the error that u r getting is very strenge b'coz i did the whole thing using access dsn,there is no question about sql server. when i run the code in my comp it ran smoothly.

choudhuryshouvi 33 Posting Pro

you can compare by taking the profile id of the harddisk being installed on a specific computer. u have to write the program in such a way that it should look for the harddisk profile id. if u want samples on how to get such element visit http://www.planet-source-code.com and search for "Disk Serial Number" under visualbasic

choudhuryshouvi 33 Posting Pro

ok, for ur convenience i've sent it to ur mail.
check it and for further references if u wish can mail me at choudhuryshouvik@gmail.com

regards
Shouvik

choudhuryshouvi 33 Posting Pro

use this code

''''''''''''''''''''''PASTE THIS INTO A MODULE''''''''''''''''''''''''''''''''
Public valnum, valsent As String
Private n, intpart, realpart, numchar, intword, realword, spltval, spltword As String
Private flag As Boolean

Public Sub WordConvert()
n = ""
intpart = ""
realpart = ""
numchar = ""
intword = ""
realword = ""
spltval = ""
spltword = ""
valsent = ""
If valnum = "." Then valnum = "0.00"
If valnum = "" Then Exit Sub

intpart = Format(Int(valnum), "000000000")
realpart = Right(valnum, 2)

spltval = realpart
Call ValFind
If spltword <> "" Then realword = spltword
spltval = Mid(intpart, 1, 2)
Call ValFind
If spltword <> "" Then intword = spltword + "Crore "
spltval = Mid(intpart, 3, 2)
Call ValFind
If spltword <> "" Then intword = intword + spltword + "Lakh "
spltval = Mid(intpart, 5, 2)
Call ValFind
If spltword <> "" Then intword = intword + spltword + "Thousand "
n = Mid(intpart, 7, 1)
Call ONES
If numchar <> "" Then intword = intword + numchar + "Hundred "
spltval = Mid(intpart, 8, 2)
If intword <> "" And Val(spltval) > 0 And realword = "" Then intword = intword + "AND "
Call ValFind
If spltword <> "" Then intword = intword + spltword
If intword <> "" …

choudhuryshouvi 33 Posting Pro

are u using internet explorer?
might IE is not supporting this download

download mozilla firefox browser from http://www.mozilla.com and try the download from that browser.

i'm telling you because i've tried downloading the file using firefox and it was successfully downloaded.

choudhuryshouvi 33 Posting Pro

Okay, I tried that now I get another error too few parameters expected 3

that because of you are calling more fields in query rather than what is restricted.
use '* from' in your query to fetch all fields from the table. then display value of only those fields which you are wanting.

Regards
Shouvik

choudhuryshouvi 33 Posting Pro

before you do what u wish u need to create an odbc dsn connection for ur ora8i database to connect it with vb6 and execute ur query statements. hope u know how to create the dsn.

after creating it,

use the following code to connect to the database from ur vb6 apps:-
**add the reference "Microsoft Activex Data Object 2.7 Library" to ur project. to add it goto project,then reference,scroll down,select it and click ok.**

Dim gCn As New adodb.Connection
Dim str As String

On Error GoTo err1

Set gCn = New adodb.Connection
str = "DSN=<your dsn name>;UID=<your db user id>;PWD=<youe db password>;DBQ="
gCn.ConnectionString = str
gCn.Open

Exit Sub
err1:
Err.Clear
Msgbox "Error in creating connection with the database."
Set gCn = Nothing
End

use the following code to configure ur recordset with the query string that u pass:-

Public Function GetResult(Cstr1 As String, typ As Integer, loc As Integer, clock As Integer) As adodb.Recordset
Dim adrs As adodb.Recordset

Set adrs = New adodb.Recordset

On Error GoTo AdoErr

adrs.CursorLocation = loc
adrs.CursorType = typ
adrs.LockType = clock
adrs.Open Cstr1, gCn

Set GetResult = adrs
Set adrs = Nothing

Exit Function

AdoErr:
MsgBox "Error : " & Err.Description, vbExclamation, "OraDB"
Err.Clear
Set GetResult = Nothing
Resume Next
End Function

use the following code to execute …

choudhuryshouvi 33 Posting Pro

use this code :-

dim i as integer

for i=1 to 12
list1.additem monthname(i)
next i

for i=0 to list1.listcount-1
printer.print list1.list(i)
printer.enddoc
next i

choudhuryshouvi 33 Posting Pro

there is simple syntax error in ur code. use the following :-
QueryOne = "Select date,time_started,time_ ended,hours_worked,customer,description From Hours where period='" & _ cboPeriod.Text & "' Order by date desc, time _started asc"
datHours.RecordSource = trim(QueryOne)

**replace all of ur fields that have
space with underscore.**

choudhuryshouvi 33 Posting Pro

use the code in the zip file.
hope it'll help you.
but before run the code create the dsn with name "exp" and mention the database path of the database "exp". the path should be where u installed the db from the zip file.

regards
Shouvik

choudhuryshouvi 33 Posting Pro

Hi all, this is my question :-

I've created a table in ms sql server 7.0 using the enterprise manager. there i've a field named "address" which is a varchar type field. now in my vb6 apps i used a multiline textbox to write address. now when i'm trying to save the address from this textbox to the table only first line is getting stored and other parts are getting ignored.

what actually happening is, when i'm typing the address without pressing the enter key it's getting stored in the table. But when i'm creating new line by pressing the enter only the first line is saving. i just can't understood what is wrong in the logic. can anybody here to help me out plz...

it's really urgent

thanks in advance...

choudhuryshouvi 33 Posting Pro

as long i know it's not a standard vb6 class
or
u haven't included the reference to the class.

choudhuryshouvi 33 Posting Pro

you have to create an ODBC connection with the access database to connect your program to the crystal report. then create an query and make the report based on that query. after that you will call the query in your program and the rest will be handled by ur apps.

first of all u have to create an query in ur access db. then...

if u r not familiar with how to create an access odbc connection plz follow the steps:-

1.goto control panel->administrative tools->database(odbc connection)
2.in user dsn tab select add
3.select microsoft access driver .mdb from list and click finish
4.enter ur dsn name(this can be anything)
5.click select and locate ur access db
6.click ok
7.then ok again to create the dsn

after creating it goto crystal report and select the dsn under the odbc section from the connection tree while u select to create a new blank report.

use the query what u created in ur db to fetch the fields from it into the report. create the report based on that query.

after this use the following code to create the query dynamically to run it from ur vb6 apps:-

Dim db As Database
Dim qdf As QueryDef
Set db = CurrentDb()
Set qdf = db.CreateQueryDef("MyQuery", "SELECT * FROM MyTable")
Set db = Nothing

then use a crystal report control and pass ur dbname,query and report name …

choudhuryshouvi 33 Posting Pro

use the code in the attachement.
hope it'll cover up query.

choudhuryshouvi 33 Posting Pro

use the attached module.
hope it'll help you.

choudhuryshouvi 33 Posting Pro

use the code in the attachment.
hope it will help you.

choudhuryshouvi 33 Posting Pro

I have created a report using crystal report 8.5
Now I want to count total no. of words that are appearing in each page of the report.

Is there a way from the crystal report software to accomplish this?

Can we create a program in vb6 to count no. of words from a report created in crystal report 8.5?

Plz reply soon.
I'll need this very much and it's very urgent.

If possible plz post some links,resources or articles even if possible sample coding here.

Thanks in advance..........

choudhuryshouvi 33 Posting Pro

use the "Like" operator

Sample sql :-

"select * from employee where emp_name like '*S*'"

choudhuryshouvi 33 Posting Pro

Hi all , this is my question :-

I have installed and created a report using crystal report 9. I used user dsn on ms access database. Now i want to know how can i show the report from my vb6 apps?

Plz help me out...
If possible plz post some links to some resources or attach some codings.

Thanks in advance.......

choudhuryshouvi 33 Posting Pro

No, the answer is all there. first in your mdb file, you must create first a query, 2nd in VB in Data Environment you must configure it because there you will connect to the database. then get your query and make some code in your form. please browse my sample program.

JIREH...............
ok man. i searched there again but found nothing. plz do me a favour. could u attach ur sample program here plz plz plz...............

plz help me out
its very very urgent

choudhuryshouvi 33 Posting Pro

I use datareport instead of crystal report o if you want try this out...
http://www.martin2k.co.uk/forums/index.php?act=Attach&type=post&id=1134

Hi jireh,
i didn't find anything there which could answer my question. Can you tell me the steps or some example codings?

choudhuryshouvi 33 Posting Pro

ok i have understood the coding. but my question was from msaccess point of view. now could u plz tell me which portion of the code should i need to modify to make it fit for accessing msaccess database.

choudhuryshouvi 33 Posting Pro

Hope this code can cover up your requirement.

Before try to run this code create a database "employee.mdb" and a table "info" with four fields "emp_no","name","basic","tax". Add some records to test the code. Take a button(cmdsearch) and five textboxes(text1 to text5) and associated five labels. Below is a sample interface that i've used. See it for your consideration.

Regards,
Shouvik

Option Explicit

Private Sub cmdsearch_Click()
Dim db As Database
Dim rs As Recordset
Dim str As String
Dim confirm As Integer

begin:
str = InputBox("Enter Employee No. :", "Search")
If str <> "" Then
Set db = OpenDatabase(App.Path & "\employee.mdb")
Set rs = db.OpenRecordset("select * from info where emp_no='" & str & "'")
If rs.RecordCount > 0 Then
Text1.Text = rs!emp_no
Text2.Text = rs!Name
Text3.Text = rs!basic
Text4.Text = rs!tax
Text5.Text = rs!basic - rs!tax
Else
confirm = MsgBox("Sorry, Employee No. " & Chr(34) & str & Chr(34) & " was not found." & vbCrLf & "Try again?", vbYesNo + vbQuestion, "Search")
If confirm = vbNo Then
Exit Sub
Else
GoTo begin
End If
End If
Set rs = Nothing
Else
confirm = MsgBox("Invalid employee no." & vbCrLf & "Try once again?", vbYesNo + vbQuestion, "Search")
If confirm = vbNo Then
Exit Sub
Else
GoTo begin
End If
End If
End Sub

choudhuryshouvi 33 Posting Pro

Hi, all this is my question:-

I am creating a double tier vb6 application with access in format 7.0 mdb. For this application i'm creating reports using crystal report 9. Now i want to show the report to view data from tables after passing some criteria.

I have a table called Quotation. There i'm storing 'quot_no ' as the primary key. Now i want to select an quotation no. from my vb6 apps and then the report will be called to show the data for the selected quotation no. only.

So, how can i do that?
Is there a way or do i have to convert my database to network db such as sql server?

Plz Reply me soon.
It's very urgent

choudhuryshouvi 33 Posting Pro

u can try this method.

within vb6 ide goto project->references
click browse and move to the location where u have saved the dll file.select the file and click ok.

u will see the file is added in the ref. list with a check marks on. now click ok.

now ur project should have no problem to access to this file.

hope this work

choudhuryshouvi 33 Posting Pro

Hi, can anyone tell me from where can I download and install the crystal reports to use in vb6?

I need the site url.
Help please...

Thanks in advance

choudhuryshouvi 33 Posting Pro

could u plz explain what do u meant by "use a collection"? if possible refer to some links.

choudhuryshouvi 33 Posting Pro

Hi, can any one tell me how to create variables during runtime.

This what we generally do when we need to create string of fixed length like -

dim x as string * 5

now i also need to do it dynamically. suppose i need to declare two individual variables of string type in runtime. as i don't know how much i need to declare so i can't do it in design mode. now if my requirement is 2 then there should have 2 variables been declared like this -

dim x as string * 5
dim y as string * 6

one more thing i can't use array in this case as i also need to define their lengths in runtime. because i think elements can be created within an array dynamically but defining size to each and every element is not possible.

So, is there any way to overcome this?
Plz..........i really need help to figure this out.

It will be great if someone post some links to such similar things here.

Thanks to all................in advance.

choudhuryshouvi 33 Posting Pro

Hi, can any one tell me how to create standalone variables during runtime.

This is what we generally do in design mode when we need to create strings of fixed length like -

dim x as string * 5

now i want to do such things dynamically. suppose i need to declare 2 individual variables in runtime of string type. as i don't know how much i need to declare, i can't declare it in design time. now if my requirement is 2 then there should have 2 vars. been declared like -

dim x1 as string * 5
dim x2 as string * 6

one more thing is that i can't use arrays in this case because also i need to define their lengths. because i think in array we can create elements dynamically but how could we define length to each & every elements in that array?

So, is there any way to overcome this?

Plz... i really need to figure this out.
So plz help me on this.

It will be great if i got such links/resources where i can get such similar things.

Thanks to all...............in advance

choudhuryshouvi 33 Posting Pro

Hi to all, here is my question:-

i've declared an user defined type like this -

public type user
str() as string
end type

where str() is an string array with empty elements. now i want to create the elements dynamically. for that i wrote these -

dim x as integer
dim s as user

x=val(txtfields.text)-1
redim s.str(x)

where x is the variable which contains total no. of elements to be passed to the array. suppose if x contains 5 then the str() will become str(5). the array will populate with 5 elements.

to this point, it's completely ok. now the crutial thing is i also need to define the size of each elements like this - str(0) as string * 5; str(1) as string * 6, etc during runtime. now how can i do that? is there any possibility?

Plz reply on this............soon

Thanks in advance........

choudhuryshouvi 33 Posting Pro

Can anybody tell me how to incorporate an windows application using vb.net and oracle 9i database as back-end? plz give me step by step instructions on this. It will be very helpful if I've got some links to websites offering such articles,tutorials and resources.

I'm using VS 2005.

Thanks in advance.
Plz.....

choudhuryshouvi 33 Posting Pro

I want to do something like we can do in VB. I have a string value which is "Dreamboy". now i would like to extract some characters from a specified position within the above string. we can do this in vb by using mid,left and right functions. now i need to know how can it be achieved in C#.

Plz tell me...............