|
Your question is more appropriate for the ASP.NET Forum[^].
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I'm currently posting the values in an HTML table as follows:
___________________________________________________
cid = Request.Form("stateabbr")
sql="SELECT State, CrossLinkFormID, DORFormID, FinalDraftDate, SubmissionDate, ApprovedDate, SubmissionNotes, AdditionalNotes FROM FormsTable WHERE State LIKE '" & cid & "%'"
rs.Open sql, conn
%>
Forms Submission for
<%Response.Write(cid)%>
<%
' Writing column headings
response.write("")%>
<%for each x in rs.Fields
response.write("")
next%>
'Writing Column values
<%do until rs.EOF%>
<%for each x in rs.Fields%>
<%next
rs.MoveNext%>
<%loop
rs.close
conn.close
%>
Select | " & x.name & " | | <%
Response.Write ("<id=" &="" x.name="" "="">" & x.value)
%> |
_________________________________________________________________
After clicking the button "Select Forms", how can I grab the values/rows in the table where the check box is check and use an sql statement to add these values/rows into a new table?
|
|
|
|
|
Your question is more appropriate for the ASP.NET Forum[^].
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Env: SQL2005 Sp2 Visual Studio 2005
Could not find stored procedure 'sbSetupDeptProfitnLoss'.
Test.sql has statement
exec sbSetupDeptProfitnLoss 1, 10,'6/1/2006'
A vb module in this project has
Partial Public Class StoredProcedures
Public Shared Sub sbSetupDeptProfitnLoss(ByVal BranchCode As Long, _
ByVal DepartmentCode As Long, _
ByVal RequestDate As Date)
Dim DepartmentName As String
Dim result As Object
Dim stDocName As String
Dim StartofMonth As Date
Dim EndOfMonth As Date
Dim StrStartofMonth As String
Dim fnBuildBudgetQuery
On Error GoTo Err_sbSetupDeptProfitnLoss
sbGetDepartmentName(DepartmentCode, DepartmentName)
StrStartofMonth = DatePart("m", RequestDate) & "/" & "01/" & DatePart("yyyy", RequestDate)
StartofMonth = StrStartofMonth
EndOfMonth = EOMonth(StartofMonth, 1)
sbBuild_L1QueryDeptSalesDetail(BranchCode, DepartmentCode, StartofMonth, EndOfMonth)
sbBuild_L1QueryDeptCostOfGoodsDetail(BranchCode, DepartmentCode, StartofMonth, EndOfMonth)
sbBuild_L1QueryDeptExpensesDetail(BranchCode, DepartmentCode, StartofMonth, EndOfMonth)
sbBuildDeptSummaryProfitnLossTable(DepartmentCode, RequestDate)
stDocName = "rptDeptProfitnLoss"
'DoCmd.OpenReport(stDocName, acPreview)
Exit_sbSetupDeptProfitnLoss:
Exit Sub
Err_sbSetupDeptProfitnLoss:
fnHandleError("sbSetupDeptProfitnLoss")
Resume Exit_sbSetupDeptProfitnLoss
Resume
End Sub
End Class
rkj
|
|
|
|
|
Did you attribute this class and the sub appropriatly for use as a stored procedure? It doesn't look like it.
Documentation on SqlProcedure attribute[^]
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thank You Very Much. That Solved the problem
rkj
|
|
|
|
|
I am writing an application that will globally add a print queue to a target PC. I can get lists from Active Directory of my print servers and my host PCs. What I'd like to do is have the user click on the print server, and my application will enumerate all print queues on that server and list them. The user will then select a print queue and a remote host, and click a button to install the printer. I can do everything except enumerate the print queues on the print server. If someone could please help with this, I'd greatly appreciate it . I am coding with Visual Studio .Net 2005 and VB .Net.
Thanks,
DotCom
Help Desk Analyst
(programmer on the side)
|
|
|
|
|
As a PS to the above, I have been able to find examples in C#, but am not able to port them to VB.
DotCom
Help Desk Analyst
(programmer on the side)
|
|
|
|
|
NFDotCom wrote: but am not able to port them to VB.
Which part of the c# code are you not able to port to VB? you can post the part your facing difficulty and someone could help
|
|
|
|
|
Search for 'WMICodeCreator'; I downloaded it from Microsoft and used it to do exactly what you are asking for.
I was able to get a list of printers on our print server and other needed information.
Tim
|
|
|
|
|
Awesome, thanks Tim! I'll check it out, and see if that works for me.
DotCom
Help Desk Analyst
(programmer on the side)
|
|
|
|
|
Thanks Tim, that will work for me. That program is going to save me from so many headaches.
|
|
|
|
|
Good... the power of a community working together...
|
|
|
|
|
Ok, I almost have it working, except I'm now get a NullReferenceException error (Object not set to an instance of an object) on the line marked with a "-->". The error is directly following this paragraph, and my sub procedure is below the error. I call the sub like this: GetPrinters("name-of-server"). If you could help me out, I'd really appreciate it.
Error details:
<br />
System.NullReferenceException was unhandled<br />
Message="Object reference not set to an instance of an object."<br />
Source="ResHelp Troubleshooter"<br />
StackTrace:<br />
at ResHelp.frmAddPrinter.GetPrinters(String strServer) in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\frmAddPrinter.vb:line 68<br />
at ResHelp.frmAddPrinter.lbxServer_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\frmAddPrinter.vb:line 80<br />
at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)<br />
at System.Windows.Forms.ListBox.WmReflectCommand(Message& m)<br />
at System.Windows.Forms.ListBox.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)<br />
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)<br />
at System.Windows.Forms.Control.WmCommand(Message& m)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)<br />
at System.Windows.Forms.ContainerControl.WndProc(Message& m)<br />
at System.Windows.Forms.Form.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)<br />
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)<br />
at System.Windows.Forms.Control.DefWndProc(Message& m)<br />
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ListBox.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)<br />
at System.Windows.Forms.Form.ShowDialog()<br />
at ResHelp.frmMain.btnGo_Click(Object sender, EventArgs e) in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\frmMain.vb:line 15<br />
at System.Windows.Forms.Control.OnClick(EventArgs e)<br />
at System.Windows.Forms.Button.OnClick(EventArgs e)<br />
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br />
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ButtonBase.WndProc(Message& m)<br />
at System.Windows.Forms.Button.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)<br />
at System.Windows.Forms.Form.ShowDialog()<br />
at ResHelp.modMain.main() in C:\Users\adamb\Desktop\ResHelp Troubleshooter\ResHelp Troubleshooter\modMain.vb:line 11<br />
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)<br />
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()<br />
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)<br />
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)<br />
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()<br />
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
at System.Threading.ThreadHelper.ThreadStart()<br />
VB Code to the sub procedure:
<br />
Private Sub GetPrinters(ByVal strServer As String)<br />
Try<br />
Dim connection As New ConnectionOptions<br />
connection.Username = Me.txtUsername.Text<br />
connection.Password = Me.txtPassword.Text<br />
connection.Authority = "ntlmdomain:" + My.Settings.Item("domain").ToString<br />
<br />
Dim scope As New ManagementScope("\\" + strServer + "\root\CIMV2", connection)<br />
scope.Connect()<br />
<br />
Dim query As New ObjectQuery("SELECT * FROM Win32_Printer")<br />
<br />
Dim searcher As New ManagementObjectSearcher(scope, query)<br />
<br />
Me.lbxPrinterShare.Items.Clear()<br />
<br />
For Each queryObj As ManagementObject In searcher.Get()<br />
'If Not (queryObj("ShareName").ToString = "''" Or queryObj("ShareName").ToString = "" Or queryObj("ShareName").ToString = Nothing) Then<br />
--> Me.lbxPrinterShare.Items.Add(queryObj("ShareName").ToString)<br />
'End If<br />
Next<br />
Catch err As ManagementException<br />
MessageBox.Show("An error occurred while querying for WMI printer data: " & err.Message)<br />
Catch unauthorizedErr As System.UnauthorizedAccessException<br />
MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message)<br />
End Try<br />
End Sub<br />
DotCom
Help Desk Analyst
(programmer on the side)
|
|
|
|
|
Well, I'm not sure...
Normally, I get the 'Name' attribute, but, my code is written to allow the user to select the desired attributes. When I selected 'ShareName', I had no errors.
Have you confirmed that you can get the sharename using the WMICodeCreator?
|
|
|
|
|
Yeah, and the crazy thing is that I can see the list of sharenames in the creator, but when I execute the code (from the creator), it gives an access denied error, and fails.
DotCom
Help Desk Analyst
(programmer on the side)
|
|
|
|
|
Ok, I figured it out. Some printers don't have share names (because they're a local printer, or for some other reason). Those printers that don't have share names would return a null result for their share name, and that is what was causing the error. I changed the query to have a where clause: "WHERE ShareName IS NOT NULL", and that fixed the issue.
|
|
|
|
|
Hi could anyone please advise on how to insert an image from a VB app into an access record in a table.
thanks
ES
|
|
|
|
|
this may help you.
Regards,
Satips.
|
|
|
|
|
I want to design an user interface where i want to change th color of the title bar of form along with the back color of the max and min buttons? how do i do that/
ciacia
|
|
|
|
|
This article might help.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
i think i have made the connection to the database. i need to know how to write the code to add and ID, surname and forename to the database. don't have a clue how to do this. can you help me?
(this is the connection)
Imports System.Data.OleDb
Public Class cust
Public conn As OleDbConnection
Public comm As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Private Sub cust_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection 'establishes that conn is a new connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PCbank.mdb" 'the name of the connection (name of the database on the end)
conn.Open() 'opens the connection
comm = New OleDbCommand 'establishes that comm is a new command
comm.Connection = conn 'the connection for the command is the connection specified
comm.CommandType = CommandType.Text 'the commands are in text
End Sub
|
|
|
|
|
|
well its jst the simple addiing in data base...
here is the code for u..
check it out....and put yr table name wherever specified tablename and make required changes
<code>Imports System
Imports System.data.oledb
Inherits System.Windows.Forms.Form
public class form1
Dim da As New OleDbDataAdapter("select * from tablename", "provider=microsoft.jet.oledb.4.0;data source=|DataDirectory|\PCbank.mdb;")
Dim ds As New DataSet
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim i As Integer
Dim str As String
'under insert button
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Try
cn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=GIVE PATH of yr mdb file;")
cn.Open()
cmd = New OleDbCommand("insert into tablename(ID,surname,forename) values('" & (TextBox1.Text) & "','" & (TextBox2.Text) & "','" & (TextBox3.Text) & ")", cn)
i = cmd.ExecuteNonQuery()
MsgBox("record inserted")
Catch ex As Exception
End Try
cn.Close()</code>
|
|
|
|
|
you can use this code also:
Public Function Query(ByVal SQL As String, ByVal OLEDBCon As OleDb.OleDbConnection, ByRef DS As DataSet) As Integer
Dim DA As New OleDb.OleDbDataAdapter(SQL, OLEDBCon)
Query = DA.Fill(DS)
DA = Nothing
End Function
Public Function Execute(ByVal SQL As String, ByVal OLEDBCon As OleDb.OleDbConnection) As Integer
Dim com As New OleDb.OleDbCommand(SQL, OLEDBCon)
com.ExecuteNonQuery()
com = Nothing
End Function
this is your connection string:
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=sample.mdb")
code of your button save:
dim strInsert as string
try
strInsert="Insert into table1 (field1,fields2...) Values('" & txt1 & "','" & txt2 & "'...)"
con.open
Execute(strInsert,con)
MsgBox("Record Saved")
con.close
end try
my code is simple.
Don't block the drive way of all the newbies in programming. )
|
|
|
|
|