|
OK. Don't vote me down for supplying a suggestion that didn't work. It was just that, not a guarantee that you could just copy'n'paste the code and whalaa, it works...
And reply to the previous message. Don't start a new thread. This will keep all the related posts together.
kewyn wrote: dim dr As Dataset2.CASHIER_INFORow
So let's see the exact code your using. At this point, I'm just guessing at what you're using and looking at.
|
|
|
|
|
hi
sorry if i sounded that way, i am just tired of this not working
Public Class form1
Inherits System.Windows.Forms.Form
Dim Reader As SqlClient.SqlDataReader
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents SqlCon As System.Data.SqlClient.SqlConnection Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents DataSet2 As logintrial.DataSet2
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.SqlCon = New System.Data.SqlClient.SqlConnection
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.DataSet2 = New logintrial.DataSet2
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataSet2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.DataSource = Me.DataSet2.CASHIER_INFO
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(48, 112)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(296, 96)
Me.DataGrid1.TabIndex = 0
'
'SqlCon
'
Me.SqlCon.ConnectionString = "workstation id=KEWYN;packet size=4096;integrated security=SSPI;data source=KEWYN;" & _
"persist security info=False;initial catalog=343344"
'SqlDataAdapter1
'
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "CASHIER_INFO", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("CashierId", "CashierId"), New System.Data.Common.DataColumnMapping("Cashier_Firstname", "Cashier_Firstname"), New System.Data.Common.DataColumnMapping("Cashier_Lastname", "Cashier_Lastname")})})
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT CashierId, Cashier_Firstname, Cashier_Lastname FROM CASHIER_INFO"
Me.SqlSelectCommand1.Connection = Me.SqlCon
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(232, 192)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 56)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 20)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(96, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(160, 20)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'DataSet2
'
Me.DataSet2.DataSetName = "DataSet2"
Me.DataSet2.Locale = New System.Globalization.CultureInfo("en-US")
'
'form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(368, 266)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.DataGrid1)
Me.Name = "form1"
Me.Text = "login"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataSet2, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim key As BindingManagerBase
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1().Fill(Me.DataSet2) 'fill the data adapter with the dataset
Me.TextBox1().Text() = ""
Me.TextBox1().PasswordChar() = "*"
key = Me.BindingContext(DataSet2, "cashier_info")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'If (Me.TextBox1.TabIndex <> -1 Or Me.CompanyComboBox.SelectedIndex <> Nothing) Then
Try
'Dim index As Integer = Me.CompanyComboBox.SelectedIndex
Dim dr As DataSet2.CASHIER_INFORow
'If Reader.Read() Then
'Me.TextBox2().Text() = Me.TextBox1.Text
Me.TextBox2().Text() = String.Format("{0}{1}", dr.CashierId)
'End If
Catch
MessageBox.Show("DID NOT WORK")
Me.Close()
End Try
End Sub
End Class
|
|
|
|
|
Oh boy, where do I begin...
kewyn wrote: Me.SqlDataAdapter1().Fill(Me.DataSet2) 'fill the data adapter with the dataset
First, this doesn't do what your comment says it does. It's just the opposite. The SqlDataAdapter fills a dataset with a copy of the record retrieve from the database.
Next, for what your code is implying, you don't need the BindingContext. So remove that line.
In your Button1_Click handler, you're misunderstanding so many concepts, from OOP to Data Sets to navigation in the data. There's just too much material to cover to fit it in a forum post. Simplify this. Just start by getting the data in your dataset shown in a textbox. Nothing more.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' It look like your SQL statement returns a single record set. This means just one table of records.
' You need to enumerate through the DataRow collection of the DataTable object in your DataSet.
' Get the individual values from each column in the row and format them for output to a String.
Dim message As String = String.Empty
For Each dr As DataRow In DataSet2.Tables(0).Rows
message = message & String.Format("{0}: {1} {2}", dr("CashierId").ToString, dr("Cashier_Firstname").ToString, dr("Cashier_Lastname").ToString)
Next
TextBox1.Text = message
End Sub
Seriously, pickup a book on VB.NET for beginners. That should help you understand the basics of OOP and clear up the misconceptions you have as shown by your code.
|
|
|
|
|
Also:
kewyn wrote: Catch
Don't catch the exception and throw it away. It usually contains informaiton that is helpful in finding the problem.
In framework 1.x a catch without specifying the exception type could be used to catch non-framework exceptions. In framework 2 they are always wrapped in a framework exception, so you should always at least specify the type Exception .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
How do you get the rectangular coordinates for Bookmarks for an existing Word.doc?
|
|
|
|
|
hi!
I am trying to display my sql data in a textbox by using the following code; this is after i have made connectiions using sqlconnection with sqldataAdapter with also a dataset
the problem code is:
sqldataAdapter
dim dr as Dataset2.CashierRow
me.TextBox2().Text()=dr.CashierId.toString
|
|
|
|
|
kewyn wrote: me.TextBox2().Text()=dr.CashierId.toString
That's not going to work. At best, you'll get "System.Data.DataRow" in the Textbox. You have to write the code that takes each row in the datatable in your dataset and formats the data in each column of that row into whatever form you need. The DataSet class doesn't know anything about how to format your data and doesn't know how to convert it's tables into formatted text strings. It's not supposed to know.
You also don't need to specify Me, and don't need to put the parenthesis after each object or property name.
TextBox2.Text = String.Format("{0} {1}", dr.columnName.Value, dr.columnName.Value)
|
|
|
|
|
I am truly stuck on this and I need despriate help with this. I have posted on MSDN and on VBforums and have no responce. I seriously need this done and I have no idea how to do it.
I am continually throwing around Ideas on how to install printer on LPR port. Here are the givens:
Port: LPR
Server providing LPD: at-cetus.ad.ufl.edu
Queue Name: CSE-211-CLQ
Driver Name: Xerox Phaser 7760GX PS
INF File Name: 7760.inf
I have tried using the registry edits to create the port and that did not work (or I have done it wrong). I have tried NshNetwork:
Code:
WshNetwork.AddWindowsPrinterConnection("\\at-cetus.ad.ufl.edu\CSE-211-CLQ", "Xerox Phaser 7760GX PS", "LPR")
However in NT and Later the LPR is ignored and I can't figure out how to get it to point to the correct inf file and crate the port. I have tried
Shell("rundll32 printui.dll, PrintUIEntry /if /b ""test_1/"" /f ""C:\7760.inf\"" /q /r ""at-cetus.ad.ufl.edu:CSE-211-CLQ/"" /m ""Xerox Phaser 7760GX PS"" /z /u")
However I can't seem to get that to work either.
Lastly I have tried Prnport.vbs as so:
Code:
cscript prnport.vbs -a -r cse-211-clq -h at-cetus.ad.ufl.edu -o lpr -q CSE-211-CLQ
But the Vista machine does not have that and I am not even sure about XP.
I am looking at WMI, however I am completely lost. PLEASE HELP! What am I doing wrong???
|
|
|
|
|
I haven't done this and I can't test it since I don't have any LPR servers around, but I think the command is:
cscript prnport.vbs -a -s serverName -r LPR -q queueName
|
|
|
|
|
However prnport.vbs is non-existent in Vista.
|
|
|
|
|
I have been searching the web high and low for anything that tells me if and how I can take a pdf and insert an image in a certain area on the document.
Does anyone know of a way to do this?
Thank you.
|
|
|
|
|
Youneed a third party PDF library to do this. Exactly how you do it depends on the library that you use. Consult it's documentation. You might want to look at this list[^] for some libraries.
|
|
|
|
|
I have the following code which works if ran on the server:
dim strProcess = "D:\Application\test.exe"
Process.Start(strProcess)
If I do this it won't work:
dim strProcess = "\\ServerName\Application\test.exe"
Process.Start(strProcess)
I can run this (\\ServerName\Application\test.exe) manually on the server, but if the service application I wrote tries to start the process, nothing happens?
Why? Any suggestions?
Lost in the vast sea of .NET
|
|
|
|
|
You could try shelling to the program, or declaring the process?
Dim sysPath As String = \\ServerName\Application\test.exe
Shell(syspath, AppWinStyle.NormalFocus, True)
Declare process
Dim udtProcess As Process = New Process
udtProcess.Start(strProcess)
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Got zinged on the previous reply..............but don't know why. Give some constructive criticism so that we can all learn - thanks!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
It's not clear where the code is stored and where it's supposed to be running. If I understand you correctly, your VB.NET code is running on a workstation, loaded from a local (non-network) source and it's trying to launch another executable from a network source?? Correct?? What type of .EXE is this second executable?? Is it a .NET app?? (Yes, it matters!)
|
|
|
|
|
The application is a VB.NET VS 2005 windows service running on a test server. The main job of this service is to look at specific network locations and if a file is put in one of these locations the service "Starts" a VB.NET application to process the file.
We had an older windows service application written in VS 2003 which used the Process.start syntax and worked well with \\Server type of addresses to fire off an executable.
The new VS 2005 app which is basically the same with a few timer enhancements to control the timing a little more, fires off applications that are defined as D:\folder\app.exe without any problems using the process.start syntax.
The executable it is firing off is a .NET 2005 with Install mode and settings under the publish option set to "application is available online only".
I tried the Shell logic locally by installing the service using InstallUtil to my system and it seems to be working better than the Process.start logic.
I have to build the setup and install it on the server to see if it works, but so far, so good.
My question, is which syntax is better. Some people would say whatever works, but I always take the approach where I like to use code that is considered correct and the latest rather than obsolete or older syntax that might not be the best way for performance or other reasons.
Any suggestions are appreciated. Hopefully this info helps and makes sense.
Lost in the vast sea of .NET
|
|
|
|
|
What account is this service running under?? If it's the LocalSystem account, it doesn't have any access to network resources, so it can't map drives to network shares and can't use UNC paths to get to them either.
There is no difference between Shell and Process.Start. They do the exact same thing using the exact same Win32 API's to do their work. Shell is outdated and not guaranteed to be there in future versions of VB.NET. It's only there for backwards compatibility with VB6 code.
You service needs to be running under an account that has permissions to the network resources you're talking about in order to work properly.
Is this "D:" drive a local drive to the workstation running the service?? Or is it a mapped drive to a network share?? If so, is there a login script that maps this drive when the user logs in??
|
|
|
|
|
> What account is this service running under??
Network logon we use for these type of applications with administrative privileges and access to all the network locations I'm trying to reach. This is also the network login I use to sign onto the server and setup scheduled tasks, etc.
> Shell is outdated and not guaranteed to be there in future versions of VB.NET. It's only there for
> backwards compatibility with VB6 code.
That is what I thought. I don't want to write code that is not guaranteed to work in the next release and forward if I can help it.
> You service needs to be running under an account that has permissions to the network resources
> you're talking about in order to work properly.
I can run the application from the server signed on with the same credentials and it works like a charm.
> Is this "D:" drive a local drive to the workstation running the service?? Or is it a mapped drive
> to a network share?? If so, is there a login script that maps this drive when the user logs in??
The D: drive is a local second hard drive on the server. If I locate the application on this drive and have the service start it, everything works fine. If I keep it on the other server where it should be, I can start it manually, but the service doesn't want to fire it off.
Lost in the vast sea of .NET
|
|
|
|
|
Was this second .EXE written under .NET (C#, VB.NET)??
If so, then you're running into the Code Access Security problem where code running from a network source is not trusted. You have to tell the .NET CLR on the machine running the code to trust the network location the code is stored on or sign the code and tell it to trust code signed with a ceratin certificate.
|
|
|
|
|
> Was this second .EXE written under .NET (C#, VB.NET)??
Yes
> If so, then you're running into the Code Access Security problem where code running from a network
> source is not trusted. You have to tell the .NET CLR on the machine running the code to trust the
> network location the code is stored on or sign the code and tell it to trust code signed with a
> ceratin certificate.
I'm going to look into this. I've seen this problem in the past and we even have a MSI file that we created to set security on workstations. I'm going to review our documentation and tweak the server with these settings and see if it helps.
Thanks!
Lost in the vast sea of .NET
|
|
|
|
|
Just remember, you have to tweak the machine that's going to be running the code, not the server where it's stored.
|
|
|
|
|
The code running is on a server and the service calling the code is on another server. Both servers are set to full trust on the code access settings for intranet in the 1.1 configuration tool found in administrative tools.
Unfortunately both apps (Service and code we're running are 2005 framework 2.0). Where do we find the configuration tool for 2.0. The framework is loaded, but the tool is not there. Is it a seperate install or is it a different process entirely?
Thanks for all your help. I believe this is definitely the issue. I'm heading out for the day, but will check for a reply if you have a chance in the remainder of the day to reply.
Thanks again!
Lost in the vast sea of .NET
|
|
|
|
|
Get the Dot Net 2.0 SDK and use mscorcfg.msc in the run window.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
I installed the Framework 2.0 SDK on the server, went to administrative tools, configuration tool for framework 2.0 and moved the Code Access Security for the Intranet Zone to Full Trust.
Restarted my service and it worked without a hitch.
Thanks for all your help!
Lost in the vast sea of .NET
|
|
|
|
|