|
how do i make the backend database in sqlserver2000 appear on the frontend visual basic form
plz show me the connection code thank u
|
|
|
|
|
The simplest way would be to add an Adodc Control from your toolbox to your form, and build the ConnectionString using the wizard.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
In order to retrevie data from backend SQL server....
You need to follow this step
1)first go to Project-References-select "Microsoft ActiveX data objects 2.1 library
2)then declare this value
Option Explicit
Dim con As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Com As New ADODB.Command
Private Sub Form_Load()
con = New ADODB.Connection
ConString = "provider=sqloledb;uid=<server uid="">;pwd=<sql server="" password="">;Initial Catalog=<database>;Data Source=<server name="">"
con.open
Then you can write code for retreiving data..
make sure that you close connection each time when you open the connection.
End Sub
|
|
|
|
|
how do i make the back end database in sqlserver2000 appear in the front end on the visual basic form
plz let me know how the connectivity is to be done
|
|
|
|
|
Dim Con As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Com As New ADODB.Command
Private Sub Form_Load()
with Con
.ConnectionString = "Data Provider=SQLOLEDB;
Provider=MSDATASHAPE;
uid=;pwd=;
Initial Catalog=dbname;
Server=server-name;"
.Open
end with
With Com
.ActiveConnection = Con
.CommandType = adCmdText
.CommandTimeout = 0 '//never time-out
.CommandText = "SELECT * FROM table-name"
End With
Rs.Open Com
Call Read '//sub defined below
End Sub
private sub Read()
Rs.MoveFirst
while not Rs.EOF
Print Rs!Field-name1 '//print to screen - whatever..
Print Rs!Field-name2
.
.
Print Rs!Field-namen
Rs.MoveNext
wend
end sub
|
|
|
|
|
I want to create an array of picture boxes (about 10) through code. I have done this succesfully and have them showing up on the form just fine. I can control the size/color and all of that fine when I create them, but after they are on the screen, I can not click on them and get it to run code. I have used the addhandler to assign a click, but when it runs, I don' know how to tell it which box I clicked on. I want to be able to have the pic box I click on change it's image to a different one. When I do this, it always changes the last box, not the one I click on. I found the arrays don't work as they did in VB 6. Please help
|
|
|
|
|
Well the event handler of PictureBox click has an object parameter called Sender, which is actually the picturebox object clicked. To do what you want, this is what you do:
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim a As PictureBox = CType(sender, PictureBox)
a.Image = .....
HTH
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
|
|
|
|
|
Hi,
I would like to know if the MSWINSCK.OCX control is the best to use to build a multiple client to server application?
Many clients can make DB request to the server. Is this MSWINSCK.OCX enough solid to handle many clients connection?
Thank you
Xelk
|
|
|
|
|
Hi every one, How I can Print a Form in VB.NET.
Johnny Lizardo
|
|
|
|
|
Do you mean print the Form from the Designer in VS.NET or print the form from the application?
RageInTheMachine9532
|
|
|
|
|
Ok.
From the application. I created a Invoice Form and I want to print that form when the user click the botton "Print" ( i created that botton).
Johnny Lizardo
|
|
|
|
|
In that case, you can start here[^] for the lowdown on printing Windows Forms. There is also example code here[^].
RageInTheMachine9532
|
|
|
|
|
I have the following problem: I need to find all cases, when a word (say 'CodeProject') is used in an MS Word file. Each time this word is found the page number should be somehow saved or displayed. I'm not familiar with VB, so I really need help! Thanks in advance!
|
|
|
|
|
I have a problem in that I am trying to call an asp page from a VB application. I have set-up a Web Browser control and use the Navigate method to run specific web pages. On the Web Browser control I have a toolbar with a Logout button. When this Logout button is clicked on, it calls an ASP page called logout.asp using the Navigate method, which is resident on the web server. This in turn will then put an entry in a log file of the user name about to be logged off, taken from the Session variable.
The call to the asp page then returns to the VB application and runs the method Form Unload, to close down the Web browser and thus log off the user.
The problem I have is that if I call the Form Unload as the next command after the call to the ASP page the logout.asp page does not seem to run.
If I remove the call to Form Unload the call to the logout.asp page works correctly and I get an entry in the log file resident on the Web server.
Can anyone shed some light on why this is happening.
Simes
|
|
|
|
|
I have a problem in that I have created a Web browser control in a VB application. This then calls various ASP web pages. Within one of these web pages a Twain component is loaded to drive an Epsom scanner. Once the scan has completed then the dialog window opened by the Twain component closes down and the windows underneath redrawn. However if you click on the close button on the Twain dialog instead, then the dialog seems to be closed down initially, but then gets re-displayed but only with the outline of the Twain dialog showing (no content is displayed and I just get a grey filled in area), covering most of the underlying browser. I obviously need to trap when the window is closed down, but I am not sure how to do this, as the supplier of the component has stated that they don't create a close event for the Twain dialog, and that it should be done through a Windows API call. But I will not know the handle of the window, and I don't want to continuously refresh the screen just to try and clear the display if someone clicks on the close button.
If the web pages are displayed on their own using IE 5 and then you click on the close button then the Twain dialog gets cleared correctly. Can anyone help me out here. Thanks.
Simes
|
|
|
|
|
Hey Simes,
It's been a while since I did something like this, but I would use the windows spy utility which lets you point at open windows and get identifying properties from them. You can find the window class for this dialog box which popups then use that class to find it again in your own program. You would have to sit in a loop watching for this window to close, i.e. you are no longer able to find it. I would also Sleep in that loop so you don't check for the close millions of times, just a couple of times a second.
If you look around for code that uses FindWindow or refer to the stuff I have pasted below for you, you should be a good way to your solution. Its a pretty good tutorial on using Findwindow. It's targeted at Microsoft Access VBA, but I'm sure you understand that this would work in VB.
Hope this is of some help.
PSS ID Number: Q210605
Article Last Modified on 05-16-2002
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Access 2000
Microsoft Visual Basic for Applications
--------------------------------------------------------------------------------
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
Summary
Through the use of a Windows application programming interface (API) function, Microsoft Access can determine if another program is already running. There may be times when you want only one instance of an application to run in Microsoft Windows. For example, if you add a command button to a form that starts the Windows Calculator (Calc.exe) program, you can start many instances of Calculator. This is an inefficient use of memory and system resources.
The API function used to determine whether a specific program is running is called FindWindow(). FindWindow() returns the handle of the window whose class is given by the lpClassName parameter and whose window name (or caption) is given by the lpCaption parameter. If the returned value is zero, the application is not running.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:
http://www.microsoft.com/partner/referral/
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
More Information
When you start a program from an icon or the command line, it registers the class name of its main window. The window class provides information about the name, attributes, and resources required by the program. The Microsoft Access window has a class name of "OMain." Additional command class names are provided at the end of this article.
By calling FindWindow() with a combination of a specific program's class name or the title bar caption, Access can determine whether that specific program is running.
You can determine the class name of an application by using Spy.exe, which is supplied with the Microsoft Win32 SDK.
If the window has a caption bar title, you can also use the title to locate the instance of the running application. This caption text is valid even when the application is minimized to an icon.
The following example shows three ways to determine if the Windows Calculator is running.
NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.
In a new database, create a module and type the following lines in the Declarations section:
Option Explicit
Option Compare Database
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Type the following procedure:
Function CalculatorUp ()
Const lpClassName = "SciCalc"
Const lpCaption = "Calculator"
'This demonstrates three different ways to call FindWindow:
'1. The ClassName only.
'2. The Caption only.
'3. Both the ClassName and the Caption
MsgBox "Calculator Handle = " & FindWindow(lpClassName, _
VBNullString)
MsgBox "Calculator Handle = " & FindWindow(VBNullString, _
lpCaption)
MsgBox "Calculator Handle = " & FindWindow(lpClassName, _
lpCaption)
'This function could return the handle of a window.
CalculatorUp = FindWindow(lpClassName, 0&)
End Function
To test this function, start Calculator, type the following line in the Immediate window, and then press ENTER:
?CalculatorUp()
Note that three message boxes open, each displaying the handle to the Calculator window. If Calculator is not running, each message box will display "0".
The following are class names of some common Windows applications:
Class Name Application
-------------------------------
SciCalc CALC.EXE
Notepad NOTEPAD.EXE
Solitaire SOL.EXE
MW_WINHELP WINHELP.EXE
MSPaintApp PBRUSH.EXE
ExploreWClass EXPLORER.EXE
WordPadClass WORDPAD.EXE
References
For more information, see the Microsoft Win32 Software Development Kit.
Additional query words:
Keywords: kbProgramming kbdta kbofficeprog
Issue Type: kbhowto
Technology: kbAccessSearch kbZNotKeyword6 kbAccess2000 kbAccess2000Search kbVBASearch kbZNotKeyword3
Nursey
|
|
|
|
|
Hey Simes,
It's been a while since I did something like this, but I would use the windows spy utility which lets you point at open windows and get identifying properties from them. You can find the window class for this dialog box which popups then use that class to find it again in your own program. You would have to sit in a loop watching for this window to close, i.e. you are no longer able to find it. I would also Sleep in that loop so you don't check for the close millions of times, just a couple of times a second.
If you look around for code that uses FindWindow or refer to the stuff I have pasted below for you, you should be a good way to your solution. Its a pretty good tutorial on using Findwindow. It's targeted at Microsoft Access VBA, but I'm sure you understand that this would work in VB.
If you need more help, please dont hesitate to shout me.
Hope this is of some help.
PSS ID Number: Q210605
Article Last Modified on 05-16-2002
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Access 2000
Microsoft Visual Basic for Applications
--------------------------------------------------------------------------------
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
Summary
Through the use of a Windows application programming interface (API) function, Microsoft Access can determine if another program is already running. There may be times when you want only one instance of an application to run in Microsoft Windows. For example, if you add a command button to a form that starts the Windows Calculator (Calc.exe) program, you can start many instances of Calculator. This is an inefficient use of memory and system resources.
The API function used to determine whether a specific program is running is called FindWindow(). FindWindow() returns the handle of the window whose class is given by the lpClassName parameter and whose window name (or caption) is given by the lpCaption parameter. If the returned value is zero, the application is not running.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:
http://www.microsoft.com/partner/referral/
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
More Information
When you start a program from an icon or the command line, it registers the class name of its main window. The window class provides information about the name, attributes, and resources required by the program. The Microsoft Access window has a class name of "OMain." Additional command class names are provided at the end of this article.
By calling FindWindow() with a combination of a specific program's class name or the title bar caption, Access can determine whether that specific program is running.
You can determine the class name of an application by using Spy.exe, which is supplied with the Microsoft Win32 SDK.
If the window has a caption bar title, you can also use the title to locate the instance of the running application. This caption text is valid even when the application is minimized to an icon.
The following example shows three ways to determine if the Windows Calculator is running.
NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.
In a new database, create a module and type the following lines in the Declarations section:
Option Explicit
Option Compare Database
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Type the following procedure:
Function CalculatorUp ()
Const lpClassName = "SciCalc"
Const lpCaption = "Calculator"
'This demonstrates three different ways to call FindWindow:
'1. The ClassName only.
'2. The Caption only.
'3. Both the ClassName and the Caption
MsgBox "Calculator Handle = " & FindWindow(lpClassName, _
VBNullString)
MsgBox "Calculator Handle = " & FindWindow(VBNullString, _
lpCaption)
MsgBox "Calculator Handle = " & FindWindow(lpClassName, _
lpCaption)
'This function could return the handle of a window.
CalculatorUp = FindWindow(lpClassName, 0&)
End Function
To test this function, start Calculator, type the following line in the Immediate window, and then press ENTER:
?CalculatorUp()
Note that three message boxes open, each displaying the handle to the Calculator window. If Calculator is not running, each message box will display "0".
The following are class names of some common Windows applications:
Class Name Application
-------------------------------
SciCalc CALC.EXE
Notepad NOTEPAD.EXE
Solitaire SOL.EXE
MW_WINHELP WINHELP.EXE
MSPaintApp PBRUSH.EXE
ExploreWClass EXPLORER.EXE
WordPadClass WORDPAD.EXE
References
For more information, see the Microsoft Win32 Software Development Kit.
Additional query words:
Keywords: kbProgramming kbdta kbofficeprog
Issue Type: kbhowto
Technology: kbAccessSearch kbZNotKeyword6 kbAccess2000 kbAccess2000Search kbVBASearch kbZNotKeyword3
Nursey
|
|
|
|
|
I have two programs
one written in VB.net and the other written in c++.
the program written in c++ calling and passing arguments to VB.net program.
let's say my VB.net program called DotNet.exe and c++ program as prog.exe
here the function how prog.exe calls DotNet.exe
lpStruct.lpParameters = "arg1 arg2 arg3" ;
I used ShellExecuteEx(lpStruct) to call the DotNet.exe
I got error at VB.Command() to read arguments passed by prog.exe
and got the following error message
<br />
The application attempted to perform and operation not allowed byt he security policy.<br />
etc.<br />
Can someone help me not to get this error message when my c++ program call my vb.net program.?
Thanks
|
|
|
|
|
i think so that you are calling a function from the .exe file
why don't you go for the .dll file?
as per my experience there is no method to call a function from a .exe file
If this is the case then Microsoft should provide .exe files for interlinking
Better way you create a .dll and get the function called
VickyMD A Specialist in Message Digest Security
|
|
|
|
|
you are correct.. I can write dll. but i had already written in VB .Net so if i can find out the way of solving the problem then I don't have to write the dll again.
but I had tried using ShellExecuteEx to call the second program and passing arguments with Visual Studio 6.0. and HAD no problem.
but after I upadated those programs to .Net and I got error message on
VB.Command() to read the arguments, which are passed by first program (written in c++) in the second program.
the error message is telling
<br />
The application attempted to perform and operation not allowed by the security policy. The operation required the SecurityException. To grant this application the required permission please contact your system administrator, or use the Microsoft .NET security policy administration tool<br />
I click on HELP on the error message and I went to Microsoft .Net security policy administration tool and did all the steps as I found in HELP.
Then it works.. I had no more error and the programs are running as I wanted.
by the way.. all the programs are on shared drived.
BUT the problem is I can't do anything from different machine.. the programs are only running perfectly from my machine.. not from other machine. and everybody else also has the permission to access that Shared Drive.
So I dont' really understand why I'm getting error running the same programs which are perfectly running from my machine?
|
|
|
|
|
hi there
well there is not a problem with .NET
actually .NET is platform independent
there a special level of security implemented in .NET
Operating systems and runtime environments typically provide some form of isolation between applications running on the system. This isolation is necessary to ensure that code running in
one application cannot adversely affect other unrelated applications.
Typically, isolation means
A) Faults in one application cannot affect other applications by bringing down the entire process.
B) Applications can be independently stopped and debugged.
C) Code running in one application cannot directly access code or resources from another application; doing so could introduce a security hole.
D) The behavior of running code is scoped by the application it runs in.
In modern operating systems, this isolation has historically been achieved using process boundaries. A process runs exactly one application and that process scopes the resources that are available for that process to use. For example, memory addresses in Win32 are process relative---a pointer in one process is meaningless in the context of another process.
The Common Language Runtime relies on the fact that code is type safe and verifiable to provide fault isolation between domains. By relying on the type safe nature of the code, application domains provide fault isolation at a much lower cost than the process isolation used in Win32.
Because isolation is based on static type verification, there is no need for hardware ring transitions or process switches. In many respects, application domains are the Common Language
Runtime equivalent of a Win32 process.
The runtime creates an application domain for each runtime application; each application domain can have an associated configuration file. Application domains isolate separate applications which run within a process. The combination of an application domain and configuration information create isolation for the application
The way in which application domains are created affects the permissions which assemblies have when running in the domain. For basic web-application scenarios, where the web page does not provide a LINK tag to a configuration file, the runtime creates an application domain on a per-site basis. Domain-neutral assemblies are only shared between application domains and assemblies with identical permission sets. A domain-neutral assembly called by two application domains with dissimilar permission sets is loaded into the domain neutral area twice. With the
exception of mscorlib of which there is only one copy of the code, all statics and local data are cloned.
An application can have multiple application domains running on its behalf. An application domain is the unit of code loading and unloading. Note that you can have multiple application domains in one process. Each type is loaded into the same application domain as its caller, or a caller can request that a type be loaded into a new application domain.
There are no direct calls between objects in different application domains;
instead, a proxy is used. Application domains can be debugged independently
so go, create a application doamin , then set its security policy and then do your work
i think that this will help you
VickyMD A Specialist in Message Digest Security
|
|
|
|
|
I wrote excel automation using VB.Net
the program takes exiting excel file name and open it, do some fixing and code for the file and let the user printpreview it. Then the program call WaitForSingleObject(hwnd,INFINITE) to pause the program until the user close the excel application.
The problem:
WaitForSingleObject() is waiting forever because the excel application process is still exit ( if you go to process of TaskManager you will see excel is still there) eventhough the user close excel and it is not on the screen anymore..
why the excel application didn't get closed and how can i make sure the excel application get closed when the user closed the application?
|
|
|
|
|
It's still running because your app is holding a reference to an Excel app object.(Excel.Application) It won't close until you release that reference. But, you can't release that reference until the user clicks Close.
RageInTheMachine9532
|
|
|
|
|
I can't release that reference until the user clicks Close.. So how could I let WaitForSingleObject knows that excel application get closed by user?
how could I resume or unpause my program when the user to close the Excel application?
|
|
|
|
|
You can't use WaitForSingleObject to do that because the process never closes. You have to get the event that Excel fires when the Workbook is closed. Excel will never close until you release that Excel.Application reference...
RageInTheMachine9532
|
|
|
|
|