|
Please send me the simplest procedure to connect SQL with VB.NET.
Umair Qayyum
|
|
|
|
|
This is the simplest procedure to connection SQL with VB.NET:
Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)
myConnection.Open()
This assumes that you have the connection string in a variable called myConnectionString.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
-- modified at 8:04 Sunday 12th February, 2006
|
|
|
|
|
Hello
i am trying to find a way that i can change the Printer.CurrentY from 1300 to 1550 for the next record and increse it by 250 for each record in the database. i have tried for next and do loop if anyone has any idea how to do this i would be most greatful.
Printer.CurrentX = 7500
Printer.CurrentY = 1300
Printer.Print RowBuf(5, i)
|
|
|
|
|
You haven't posted any For/Next loop code, so it's impossible to tell you what went wrong. It's been over 5 years since I touched VB6, so let's see:
Dim i As Long
For i = 0 to 10
' More printer code...
Printer.Y = Printer.Y + (i * 250)
' Whatever else you're printing...
Next i
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks dave here is the code that i am trying to use. i added you bit but it prints like this
aaaa
bbbb
cccc
not like aaaa bbbb cccc
i hope this helps
Do Until rs.EOF
RowBuf = rs.GetRows(5000)
RowsReturned = UBound(RowBuf, 2) + 1
For i = 0 To RowsReturned - 1
For s = 0 To 10
Printer.CurrentX = 500
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(2, i)
Printer.CurrentX = 2000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(3, i)
Printer.CurrentX = 2750
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(4, i)
Printer.CurrentX = 6000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(6, i)
Printer.CurrentX = 7500
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(5, i)
If adoMeds.Recordset.Fields("finish") <> "None" Then
Printer.CurrentX = 9000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(7, i)
Else
Printer.CurrentX = 9000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print " "
End If
Next s
Next i
Loop
|
|
|
|
|
sorry i did try Printer.CurrentY = Printer.CurrentY + (s * 250)
with the same result as with the +
bolson50 wrote: thanks dave here is the code that i am trying to use. i added you bit but it prints like this
aaaa
bbbb
cccc
not like aaaa bbbb cccc
i hope this helps
Do Until rs.EOF
RowBuf = rs.GetRows(5000)
RowsReturned = UBound(RowBuf, 2) + 1
For i = 0 To RowsReturned - 1
For s = 0 To 10
Printer.CurrentX = 500
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(2, i)
Printer.CurrentX = 2000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(3, i)
Printer.CurrentX = 2750
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(4, i)
Printer.CurrentX = 6000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(6, i)
Printer.CurrentX = 7500
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(5, i)
If adoMeds.Recordset.Fields("finish") <> "None" Then
Printer.CurrentX = 9000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print RowBuf(7, i)
Else
Printer.CurrentX = 9000
Printer.CurrentY = Printer.CurrentY + (s + 250)
Printer.Print " "
End If
Next s
Next i
Loop
|
|
|
|
|
thanks dave i did play with it some more and got it to work here is the code i used.
Dim s As Long
Dim sp As Long
For i = 0 To RowsReturned - 1
sp = Printer.CurrentY = 1300
s = Printer.CurrentY + (sp + 0)
Printer.CurrentX = 500
Printer.CurrentY = s
Printer.Print RowBuf(2, i)
Printer.CurrentX = 2000
Printer.CurrentY = s
Printer.Print RowBuf(3, i)
Printer.CurrentX = 2750
Printer.CurrentY = s
Printer.Print RowBuf(4, i)
Printer.CurrentX = 6000
Printer.CurrentY = s
Printer.Print RowBuf(6, i)
Printer.CurrentX = 7500
Printer.CurrentY = s
Printer.Print RowBuf(5, i)
If adoMeds.Recordset.Fields("finish") <> "None" Then
Printer.CurrentX = 9000
Printer.CurrentY = s
Printer.Print RowBuf(7, i)
Else
Printer.CurrentX = 9000
Printer.CurrentY = s
Printer.Print " "
End If
Next i
|
|
|
|
|
BC30108: 'FormsAuthenticationTicket' is a type and cannot be used as an expression.
objTicket = FormsAuthenticationTicket(2, textUsername.Text, DateTime.Now.AddMinutes(30), False, dtrRoles)
|
|
|
|
|
Have you missed out the New keyword?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hi,
I have an web application running on a applicationserver. Now I want to shutdown local software on the client from the browser.
I use asp.net but I realized I needed av VBscript to execute on the local client to be able to get a handle for the local applicaition that I want to shutdown. But how do I use the WINAPI methods sendMessage and findWindow in VBscript. I know I have to import user32.dll.
Im really bad at scripting...)
THANKS!
Ibana
|
|
|
|
|
VBScript, or any script running in a browser for that matter, has absolutely no access to the Win32 Api. It's impossible to do what you want from inside a browser session without the user downloading, installing, and allowing script to execute, a custom COM object that does the same thing.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for your replay,
Do you have any suggestion how to access the winapi on the local machine from my asp.net/C# application running on a server. I need to use the winapi to shutdown a local installed software.
Should a make a small app that runs on the local machine that calls the winapi? Are there any better solutions?
/ibana
|
|
|
|
|
There is NOTHING in your ASP.NET code that can get to the client machine. It's IMSPOSSIBLE. Your app will have absolutely no permissions onthe local machine.
Also, script running inside a browser session will not have any access to other processes running outside the browser session and has no access to any client hardware or system resources.
The user MUST install a component to do this, and it will ONLY work if security inside the browser is stripped down to nothing! Your web app cannot stop a process outside the browser, period, unless the user turns the security for the zone your code came from down to nothing! This is something that no sane network admin on earth would do!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know this is a bit old discussion, but thought of sharing this:
Info/Theory:
~~~~~~~~~~~
User32.dll is the source of many of the most common Windows API's, that allow you to
interact with the operating system at a lower level.
Please check: https://social.msdn.microsoft.com/Forums/windows/en-US/b04153ff-e4fb-4500-a8e4-3a685208af57/when-to-use-user32dll-and-how?forum=winforms
Following is the code to access Win32 API using VBSCript.
---------------------------------------------------------
' --------------- Start of Code ------------------------------------------------------------
Dim excel
Set excel = CreateObject("Excel.Application")
Dim strMacro
strMacro = "CALL('user32', 'MessageBoxA', 'JJCCJ', 0, 'Hello, Win32 API(VBScript) World - My call via User32 dll!', 'Hello, World!', 0)"
strMacro = Replace( strMacro, "'", """" )
excel.ExecuteExcel4Macro( strMacro )
'---------------- End of Code --------------------------------------------------------------
Copy the above to a notepad & save it as : myMessage.vbs and double click it.
Expected Result: Please see the script in action : Windows API VBScript Calling User32 DLL directly - YouTube[^]
|
|
|
|
|
That's cute and all, but it also requires Office be installed on the machine in order to work and that's not going to be the case on every machine.
Frankly, using Excel as an intermediary just to run a single line of code is a very heavy cost and a bit ridiculous.
|
|
|
|
|
This only happens if you have any of the following type of laptops:
a) Mac / MacBook with IoS
b) Laptop used exclusively for non-MS office testing
c) New Laptop with no MS Office Installed
d) Loaner laptop with no MS Office
e) Sometimes if you have had a crash of MS Office on your laptop - then also the Excel Application
will not work - for this.
f) if your enterprise IT has disabled using MS Office COM Objects and/or restricted authorization
to use MS Office COM objects/APIs.
ELSE I do not know of any other reason - any laptop not having MS Office installed.
But the solution does work - and you do not need to use any other tools.
Good luck.
|
|
|
|
|
First, using a heavy weight application, like Excel, to call a couple of Win32 API's is ridiculous.
Also, going back to the original context of the question, the script, running in a browser, can NOT create an instance of Excel. COM-interop is off-limits because of security concerns. It's also the reason ActiveX is no longer supported by browsers.
|
|
|
|
|
Does anyone know a way for me to use a Windows icon that is stored on the Shell32.DLL file? I'm sure there is a Windows API call for this but I can't find it.
For example: If I selected a Drive from the DriveList control I want the icon for the selected drive to show up on the Treeview control as the root node.
Thank you
Quecumber256
|
|
|
|
|
You mean this[^] little article on CP...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, I mean using a call to the Shell32.DLL to retrieve a specific icon from their list.
Thank you,
Quecumber256
|
|
|
|
|
You don't!! You use the Extract icon method to get the icons out of the file, just like Shell32 does. Shell32 won't pick the icon for your, but it will tell you what type each drive is. You then have to use that information to pick the icon to show.
What do you need to determine the drive type? Easy! Call the Win32 Api function <a href="http://msdn.microsoft.com/library/en-us/fileio/fs/getdrivetype.asp?frame=true" rel="nofollow">GetDriveType</a>[<a href="http://msdn.microsoft.com/library/en-us/fileio/fs/getdrivetype.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] , or <a href="http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/RealDriveType.asp?frame=true" rel="nofollow">RealDriveType</a>[<a href="http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/RealDriveType.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] .
You can find the P/Invoke Declares on P/Invoke.net if you have trouble figuring it out, or you could just ask...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 21:29 Saturday 11th February, 2006
|
|
|
|
|
Hello
my english is not good; escuse me for that.
I'd like to know how can I import my phonebook from outlook express to my database; I'm using ms access 2003 and VBA.
thanks
|
|
|
|
|
Without getting into the overly-convoluted and gory details of calling the Win32 Api functions to export the address book...
Go into Outlook Express, click the File menu, Export, and export the address book to a Text (CSV) file. You can the easily go into Access and import the data from that file.
But, if you must do this in code, there is only one place to get the API documention anymore, here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am unable to set parameter to crystal report. Report source is SQL Server Stored Procedure. Please help me.
|
|
|
|
|
Is there any grid control in vs 2003 along with DataGrid. I want to use DataGridView in VS2003
|
|
|
|