|
hi,
can i create sql query in query builder by selecting sql views instead of selecting sql tables??
please someone help me...!
|
|
|
|
|
What does this have to do with writing code in Visual Basic.NET??
|
|
|
|
|
He wants to Visualize the answer in the most Basic way possible?
|
|
|
|
|
Member 12094561 wrote: can i create sql query in query builder by selecting sql views instead of selecting sql tables?? Yes it is possible, just reference the views as you would reference any table.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
In a vb.net 2010 desktop application, I want to use 2 values for rowfilter and sort in a dataset, but I do not know how to accomplish that goal. The 2 values that I want to use for rowfilter and sort are the following: Variables.g_strCatId & CType(sItemEntered, String)
Here is the code that I have so far:
Public Sub FilllstItem2(ByVal sItemEntered As Integer) Dim dtInv As DataTable = dsRpt.Tables("tblItemData") Dim dv As New DataView(dtInv) Dim i As Integer
With dv
.RowFilter = "RecordID = '" & Variables.g_strCatId & CType(sItemEntered, String) & "'"
.Sort = "RecordID"
End With
If dv.Count > 0 Then
For i = 0 To dv.Count - 1
lstboxItems.Items.Add(CType(dv.Item(i)("ItemNo"), String) & " - " & CType(dv.Item(i)("Description"), String))
Next i
Else
End If
dv.Dispose()
ReDim itemArray(lstboxItems.Items.Count)
End Sub
Thus would you show me how to modify the code that I just listed above so that I can pass the 2 values of Variables.g_strCatId & CType(sItemEntered, String) to the rowfilter and sort code that I listed below:
to With dv .RowFilter = "RecordID = '" & Variables.g_strCatId & CType(sItemEntered, String) & "'" .Sort = "RecordID" End With
Is there a way to use a linq statement instead? If so, can you show me the code to use the linq statement?
|
|
|
|
|
OK, so you're already passing two variables to the sort filter. You're combining some value of g_strCatId with whatever value is in sItemEntered into a single string and sending that to the RecordId, as a string.
Your resulting filter looks something like this:
RecordId = 'SomeCarId0000123'
Is that what you want?
Without a much better explanation of how this filter is supposed to work and how it should be using the values supplied, there's little anyone can do to help.
|
|
|
|
|
You are correct on the value passed to the recordid. I did end up using linq to solve my problem.
|
|
|
|
|
how can i code my software to auto start at windows startup?
|
|
|
|
|
|
That's called a "service application". Windows starts services before users get a chance to log in.
|
|
|
|
|
I can't make my listbox height same as my textbox in a form, how do I resize the listbox as I wanted.
|
|
|
|
|
Try setting the Listbox's IntegralHeight property to False
|
|
|
|
|
I got 'em right now, thanks buddy, you are a big help
|
|
|
|
|
I am completely new to vb programming or programming in general! I am a 30 year old want to be programmer but it is so hard for me to understand any languages at all. I tried visual basic many years ago and never got the hang of it at all. This is my first serious attempt at any programming. Well on with my question. I need to make a program that will
1. check to see if device is connected
2. install an .apk file
3. install another .apk file
4. push a folder with preinstalled apps into said directory
I am trying to make a program for my phone. I will be using adb and adb commands. I would like to distribute this with my friends but when I run the program on there computer it says directory not found, then it shows my directory on their computer. Please help so confused
|
|
|
|
|
Member 12079859 wrote: when I run the program on there computer it says directory not found
Can you provide us the line of code that threw this exception, as well as how the variable(s) it is using are declared and assigned?
I never finish anyth
|
|
|
|
|
Imports System.IO
Imports System.Threading
Imports System.Windows.Forms.DialogResult
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not Directory.Exists("ADB") Then
Directory.CreateDirectory("ADB")
Else
If Not File.Exists("ADB\adb.exe") Then
File.WriteAllBytes("ADB\adb.exe", My.Resources.adb)
End If
If Not File.Exists("ADB\AdbWinApi.dll") Then
File.WriteAllBytes("ADB\AdbWinApi.dll", My.Resources.AdbWinApi)
End If
If Not File.Exists("ADB\AdbWinUsbApi.dll") Then
File.WriteAllBytes("ADB\AdbWinUsbApi.dll", My.Resources.AdbWinUsbApi)
End If
If Not File.Exists("ADB\fastboot.exe") Then
File.WriteAllBytes("ADB\fastboot.exe", My.Resources.fastboot)
End If
End If
If Not Directory.Exists("Addon") Then
Directory.CreateDirectory("Addon")
Else
If Not File.Exists("Addon\Firestarter.apk") Then
File.WriteAllBytes("Addon\Firestarter.exe", My.Resources.Firestarter)
End If
End If
End Sub
Function adb(ByVal Arguments As String) As String
Try
Dim My_Process As New Process()
Dim My_Process_Info As New ProcessStartInfo()
My_Process_Info.FileName = "cmd.exe" ' Process filename
My_Process_Info.Arguments = Arguments ' Process arguments
My_Process_Info.WorkingDirectory = "/c"
My_Process_Info.CreateNoWindow = True
My_Process_Info.UseShellExecute = False
My_Process_Info.RedirectStandardOutput = True ' Redirect (1) Output
My_Process_Info.RedirectStandardError = True ' Redirect non (1) Output
My_Process.EnableRaisingEvents = True
My_Process.StartInfo = My_Process_Info
My_Process.Start() ' Run the process NOW
Dim Process_ErrorOutput As String = My_Process.StandardOutput.ReadToEnd() ' Stores the Error Output (If any)
Dim Process_StandardOutput As String = My_Process.StandardOutput.ReadToEnd() ' Stores the Standard Output (If any)
' Return output by priority
If Process_ErrorOutput IsNot Nothing Then Return Process_ErrorOutput ' Returns the ErrorOutput (if any)
If Process_StandardOutput IsNot Nothing Then Return Process_StandardOutput ' Returns the StandardOutput (if any)
Catch ex As Exception
Return ex.Message
End Try
Return "OK"
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
MsgBox(adb("/c adb devices"))
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim sr As New IO.FileStream("", IO.FileMode.Open)
Dim sw As New IO.FileStream("[copyto]", IO.FileMode.Create)
Dim len As Long = sr.Length - 1
Dim buffer(1024) As Byte
Dim bytesread As Integer
While sr.Position < len
bytesread = (sr.Read(buffer, 0, 1024))
sw.Write(buffer, 0, bytesread)
ProgressBar1.Value = CInt(sr.Position / len * 100)
Application.DoEvents()
End While
sw.Flush()
sw.Close()
sr.Close()
MsgBox(adb("/c adb install Firestarter.apk"))
End Sub
I'm embarrassed because this is about 4 guys just who have no idea and just winging code together. Only one guy has some and i mean very little experience. Any suggestions help. Trying to figure out how to allow other computer or phone to find the program or have it installed or uploaded to their device if that makes any sense. Thank you so much
modified 23-Oct-15 8:10am.
|
|
|
|
|
When you write
If Not Directory.Exists("someDirectoryName") Then
(and ditto for File.Exists ), then you need to pass the full path, not the relative one. You can use
If Not Directory.Exists(Application.StartUpPath & "\someDirectoryName") Then
|
|
|
|
|
Message Closed
modified 16-Oct-15 5:06am.
|
|
|
|
|
A question so good you thought it needed asking three times?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Imports System.Data.OleDb
Public Class Inquiry_Form
Dim provider As String
Dim dataFile As String
Dim connstring As String
Dim myConnection As OleDbConnection = New OleDbConnection
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
provider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
dataFile = "Database3.mdb"
connstring = provider & dataFile
myConnection.ConnectionString = connstring
myConnection.Open()
Dim str As String
str = "INSERT INTO Inquiry_Form([Date],[RefNo],[NameP],[Address],[Age],[PhoneNo],[MobileNo],[EmailAd],[ReferralQuestion],[Type_of_Unit],[Date_of_Purchase],[Purpose_of_Purchase],[Monthly_Income],[RName],[RAddress],[RMobileNo],[R2Name],[R2Address],[RMobileNo],[R2Name],[R2Address],[R2MobileNo],[AgentsName]) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
cmd.Parameters.Add(New OleDbParameter("Date", CType(TextBox1.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RefNo", CType(TextBox2.Text, String)))
cmd.Parameters.Add(New OleDbParameter("NameP", CType(TextBox3.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Address", CType(TextBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Age", CType(TextBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("PhoneNo", CType(TextBox6.Text, String)))
cmd.Parameters.Add(New OleDbParameter("MobileNo", CType(TextBox8.Text, String)))
cmd.Parameters.Add(New OleDbParameter("EmailAd", CType(TextBox7.Text, String)))
cmd.Parameters.Add(New OleDbParameter("ReferralQuestion", CType(ComboBox1.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Type_of_Unit", CType(ComboBox2.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Date_of_Purchase", CType(ComboBox3.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Purpose_of_Purchase", CType(ComboBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Monthly_Income", CType(ComboBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RName", CType(TextBox10.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RAddress", CType(TextBox11.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RMobileNo", CType(TextBox15.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2Name", CType(TextBox12.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2Address", CType(TextBox13.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2MobileNo", CType(TextBox14.Text, String)))
cmd.Parameters.Add(New OleDbParameter("AgentsName", CType(TextBox16.Text, String)))
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myConnection.Close()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox8.Clear()
TextBox7.Clear()
TextBox10.Clear()
TextBox11.Clear()
TextBox15.Clear()
TextBox12.Clear()
TextBox13.Clear()
TextBox14.Clear()
TextBox16.Clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
Menu_Page.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
Inquiry_FormBindingSource1.AddNew()
End Sub
Private Sub Inquiry_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database3DataSet.Inquiry_Form' table. You can move, or remove it, as needed.
Me.Inquiry_FormTableAdapter.Fill(Me.Database3DataSet.Inquiry_Form)
End Sub
End Class
|
|
|
|
|
A likey explanation is that you haven't closed the connection in some other part of your code.
|
|
|
|
|
That is why it is recommended to create a connection in the method where you need it, and to wrap it in a using-block to ensure disposing. It might sound expensive to create a new connection-object, but it is not. Hunting for these kinds of bugs is however.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You attempt to execute an INSERT statement which specifies 23 columns, but only inserts 20 values.
That throws the "Number of query values and destination fields are not the same" exception.
Your code then fails to close the connection, so the next time you click the button, you get the "Not allowed to change the 'ConnectionString' property..." exception.
As the others have said, create your connection object inside the method, and wrap it in a Using block[^] to ensure that it is always disposed of properly.
Make sure your INSERT statement has the same number of parameter placeholders in the VALUES part as the number of columns in the INSERT INTO part.
There's no need to convert the Text property to a string, as it's already a string.
You can simplify adding the parameters by using the AddWithValue method.
You should avoid catching the general Exception type. Only catch the exceptions that you want to handle. In this case, System.Data.Common.DbException is the only one you want to catch.
Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database3.mdb"
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Const CommandText As String = "INSERT INTO Inquiry_Form([Date], [RefNo], [NameP], [Address], [Age], [PhoneNo], [MobileNo], [EmailAd], [ReferralQuestion], [Type_of_Unit], [Date_of_Purchase], [Purpose_of_Purchase], [Monthly_Income], [RName], [RAddress], [RMobileNo], [R2Name], [R2Address], [RMobileNo], [R2Name], [R2Address], [R2MobileNo], [AgentsName]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
Using connection As New OleDbConnection(ConnectionString)
Using cmd As New OleDbCommand(CommandText, connection)
cmd.Parameters.AddWithValue("Date", TextBox1.Text)
cmd.Parameters.AddWithValue("RefNo", TextBox2.Text)
cmd.Parameters.AddWithValue("NameP", TextBox3.Text)
cmd.Parameters.AddWithValue("Address", TextBox4.Text)
cmd.Parameters.AddWithValue("Age", TextBox5.Text)
cmd.Parameters.AddWithValue("PhoneNo", TextBox6.Text)
cmd.Parameters.AddWithValue("MobileNo", TextBox8.Text)
cmd.Parameters.AddWithValue("EmailAd", TextBox7.Text)
cmd.Parameters.AddWithValue("ReferralQuestion", ComboBox1.Text)
cmd.Parameters.AddWithValue("Type_of_Unit", ComboBox2.Text)
cmd.Parameters.AddWithValue("Date_of_Purchase", ComboBox3.Text)
cmd.Parameters.AddWithValue("Purpose_of_Purchase", ComboBox4.Text)
cmd.Parameters.AddWithValue("Monthly_Income", ComboBox5.Text)
cmd.Parameters.AddWithValue("RName", TextBox10.Text)
cmd.Parameters.AddWithValue("RAddress", TextBox11.Text)
cmd.Parameters.AddWithValue("RMobileNo", TextBox15.Text)
cmd.Parameters.AddWithValue("R2Name", TextBox12.Text)
cmd.Parameters.AddWithValue("R2Address", TextBox13.Text)
cmd.Parameters.AddWithValue("R2MobileNo", TextBox14.Text)
cmd.Parameters.AddWithValue("AgentsName", TextBox16.Text)
Try
connection.Open()
cmd.ExecuteNonQuery()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox8.Clear()
TextBox7.Clear()
TextBox10.Clear()
TextBox11.Clear()
TextBox15.Clear()
TextBox12.Clear()
TextBox13.Clear()
TextBox14.Clear()
TextBox16.Clear()
Catch ex As System.Data.Common.DbException
MsgBox(ex.Message)
End Try
End Using
End Sub
You should also give your controls meaningful names, rather than accepting the default names created by the designer. You might remember that TextBox11 is the "RAddress" now, but when you come back to this code in a few months, you'll be cursing yourself for leaving the controls with the default names!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi
you have wrong in fields names
[R2Name],[R2Address],[RMobileNo],[R2Name],[R2Address],[R2MobileNo]
it is repeated so you have error
|
|
|
|
|
Can anybody help me create VB Script that I can use to gather the NIC Card Configuration for a list of Servers and store the information into an Excel Spread Sheet.
The Servers will have multiple Network Cards in use and I require the IP, Subnet and Gateway for each one in use.
Any help greatly appreciated!!
|
|
|
|
|