samir_ibrahim 58 Junior Poster

What type of movie info you are searching exactly? since you decide to search for movie name why don't you check www.imdb.com which will give you only movie name to look at despite wikipedia which will give a long list of non movie name.

samir_ibrahim 58 Junior Poster

Glad I helped.

Have a nice day.

samir_ibrahim 58 Junior Poster

I have saved the column name as 'Serial No' with quotes also in the name,only beacause of the space issue

Very nice from you.

Are you aware that putting the field name between quotes is INVALID ?

samir_ibrahim 58 Junior Poster

I had read somewhere that either MySQl or ODBC does not accept named parameter.

Let update query be:

Dim cmd As New OdbcCommand("insert into table2(name) values (?)", con)
cmd.Parameters.AddWithValue("?", TextBox1.Text)

'PS: I also try it with putting only ? in the insert sql and put a name in the AddWithValue and it works
Dim cmd As New OdbcCommand("insert into table2(name) values (?)", con)
cmd.Parameters.AddWithValue("?Name", TextBox1.Text)

hth

samir_ibrahim 58 Junior Poster

I begin recently large excel automation & manipulation project. and I have vs2008 and office 2007

First, I note that when I use HDR=YES in the connection string, it ask for ISAM driver so I omit it and my connection string became like this.

Dim _xls_loc = "c:\test.xls"
Dim _xls_cnn_str As String = "Provider=Microsoft.Jet.OleDb.4.0;data source=" & _xls_loc & ";Extended Properties=Excel 8.0;"

Second, you have to decide how you want to deal with the sheet name as a table, it is kinda tricky. I know 3 ways

select * from [sheet1$]
Select * From [sheet1$A1:B10]

or this one which i am currently using, create a Name for the excel range you want to use. in excel 2007 you have to go Formulas >> Define Name after you select the range you want to use and give it a name, then you can use this name in the excel as select * from mynamedexcel Don't forge to use [] when dealing with field name contains spaces such as [Serial No] not 'Serial No'

try this

ast_liab_excelcmd.CommandText = "UPDATE [AssetsLiabilities$] SET " & ast_liab_updatecmd1 & " WHERE [Serial No] = '" & TextBox1.Text & "'"

this is a good site for Excel ADO & automation
http://www.homeandlearn.co.uk/excel2007/excel2007s7p6.html

hth

samir_ibrahim 58 Junior Poster

As Scott told you, you have to refill the DataSet, but there is another solution also.

in case you are using Dataset, I suggest create the the variable that will hold the DataSet as public in a Modlue

Add a module to your project, in the module declare the variable Dim MyDS as New DataSet, and use this variable in both forms.

hth

samir_ibrahim 58 Junior Poster

can not create odbc connection as well.what's wrong?

You had mentioned before that you have a MSSQL server, what is the OS of that server? Win Server 2000 or 2003 or 2008?

When you tried to create the ODBC, in the second page where it ask you "How should sql Server verify ....." there is a button "Client Configuration" click on it and check what it gives you, try to change the server name to IP address.

samir_ibrahim 58 Junior Poster

Hi adatapost

Thank you very much for this clever idea (create the DataSet as class)

I managed to do it by creating dummy DataSet at design time, but your way is much more better.

It take me long time to put it in my project since i am filling a DataGridView by hand then I have to convert the information in DataGridView to your DataSet and then run the reports.

It works like charm.

Thanks.

samir_ibrahim 58 Junior Poster

In what Line it give this error?

Check if you declare the variable for DataReader twice (once as public and once a local in another place)

samir_ibrahim 58 Junior Poster

It could be a firewall problem as murid pointed out.
- What is the OS that the MSSQL is install on?

Try to:
- from any client pc, Go to control panel >> administrator tool >> Data Source (ODBC) and try to create a connection from there.

Does it succeed?

samir_ibrahim 58 Junior Poster

I agree with sknake that you can use MSSQL 2005/2008 Express Edition as a server and multiple clients/user can connect to it.

You have to take into consideration that in express edition the DB size limit is 4GB and you cannot use it as publisher for replication.

For more info.
http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx?PHPSESSID=0324345d45ef1bf1f764044e03584cd0

samir_ibrahim 58 Junior Poster

Hi

I have a dataset created programatically and I want to use this dataset to bind it to Microsoft ReportViewer.

I tried the Microsoft ReportViewer with DataSet created at design time and it works well.

I have searched a lot and this is the best thing I can find but I see it not logical to create object that simulate the fields in the table. http://aspalliance.com/762

does any one have any thought of how to do it that in case it could be done.

Here is my trial code which is no working

Dim sqlcn As New SqlConnection("server=myserver;uid=myuser;pwd=mypassword;database=mydatabase;")
Dim sadapt As New SqlDataAdapter("select * from mytable", sqlcn)
Dim ds As DataSet = New DataSet
sadapt.Fill(ds, "ds_mytable")
Me.DataGridView1.DataSource = ds.Tables(0)
BindingSource1.DataSource = ds
BindingSource1.DataMember = "ds_mytable"
Dim rptSource1 As New Microsoft.Reporting.WinForms.ReportDataSource
rptSource1.Name = "test"
rptSource1.Value = Me.BindingSource1

Me.ReportViewer1.LocalReport.DataSources.Add(rptSource1)
Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "testing.Report1.rdlc"
Me.ReportViewer1.RefreshReport()
samir_ibrahim 58 Junior Poster

Glad that you solve your problem.

Could you please mark the thread as solved?

Have a nice day.

samir_ibrahim 58 Junior Poster

What do you mean by "its worked for local machine."?
You installed Sql server locally on a macine and your code works? how the client suppose to connect (also locally or remotely)?

Check if you change the password for the administrator.

kvprajapati commented: Good point. +11
samir_ibrahim 58 Junior Poster

First check this http://support.microsoft.com/kb/905719

When you issue Me.Close() the form still reside in the memory and the object inside it are still exist (not destroyed)

Try this
in the button that close the Dialog put this
Me.Close()
Msgbox(Me.Text) <-- this will give you the name of the of the form but you close it?

now try this

Me.Dispose()
MsgBox(Me.Text) <-- the Dispose will release the form and all it is object.

hth

samir_ibrahim 58 Junior Poster

How you are opening/closing the second form? post code.

samir_ibrahim 58 Junior Poster

That mean FindlvItem did not find that you are searching for.

Remember that you are searching for ItemName, if you want to search for ItemNo you had to change thelSingleItem.Name = txtItemName.Text.Trim to move it up so will be after this line lSingleItem = ListView1.Items.Add(txtItemNo.Text.Trim)

With Me.ListView1
'.Items.Clear()
.Sorting = SortOrder.Ascending
lSingleItem = ListView1.Items.Add(txtItemNo.Text.Trim) 'Create a new line, and assign the ListItem into the variable so we can add sub items
 lSingleItem.Name =txtItemNo.Text.Trim ' this will act as a Key 
lSingleItem.SubItems.Add(txtItemName.Text.Trim) 'The first sub item for the first line

lSingleItem.SubItems.Add(txtUnitPrice.Text) 'The second sub item for the first line
lSingleItem.SubItems.Add(txtQty.Text.Trim)
lSingleItem.SubItems.Add(txtUnitTotal.Text)
lSingleItem.SubItems.Add(txtDescription.Text)
End With
samir_ibrahim 58 Junior Poster

heres the code

Dim Total As Decimal
Dim lSingleItem As ListViewItem 'The variable will hold the ListItem information so that you can add values to the column you want to change
Dim li As ListViewItem
Dim lngRunningTotal As Decimal
Dim item As String = ""

With Me.ListView1
'.Items.Clear()
.Sorting = SortOrder.Ascending
lSingleItem = ListView1.Items.Add(txtItemNo.Text.Trim) 'Create a new line, and assign the ListItem into the variable so we can add sub items
lSingleItem.SubItems.Add(txtItemName.Text.Trim) 'The first sub item for the first line
lSingleItem.Name = txtItemName.Text.Trim ' this will act as a Key
lSingleItem.SubItems.Add(txtUnitPrice.Text) 'The second sub item for the first line
lSingleItem.SubItems.Add(txtQty.Text.Trim)
lSingleItem.SubItems.Add(txtUnitTotal.Text)
lSingleItem.SubItems.Add(txtDescription.Text)
End With

Add this to the end of the code

Replace the 1000 inside the Find with the ID you are searching for

Dim FindlvItem() As ListViewItem
FindlvItem = Me.ListView1.Items.Find("1000", False)
FindlvItem(0).SubItems(3).Text = 9999

hth

samir_ibrahim 58 Junior Poster

Could you post your code ?

samir_ibrahim 58 Junior Poster

Hi guys,

Currently I am updating a listview with data in it via clicking on the selected row and displaying that row data onto textboxes and then updating it. What the data has is ID number follow name and QTY. What I want to add to this function is to update the quantity of a specific ID without clicking on the specific row in listview but by searching the ID, returning its results in the textbox, update it .

I guess your best choice is to find ID using the ListView1.Items.Find(Key) but that depends on how you are populating the Listview. or Loop through the listview and search for text inside specific column.

How you are populating the listview?

samir_ibrahim 58 Junior Poster

Pls see my code.Nothing is displaying in the grid

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Dim connString As String = "Provider=SQLOLEDB;Data Source=MSALAMEEN;uid=sa;pwd=Sa1;Initial Catalog=Biometric"
        Dim myConnection As OleDbConnection = New OleDbConnection
        myConnection.ConnectionString = connString
        Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select ID from bdata", myConnection)
        Dim ds As DataSet = New DataSet
        Dim dc1 As DataColumn = New DataColumn
        'da.Fill(ds)
        da.Fill(ds, "bdata")
        dc1 = ds.Tables("bdata").Columns("id")
        DataGridView1.DataSource = ds.DefaultViewManager

Try this,
After the last line add DataGridView1.DataMember = "bdata"

kvprajapati commented: Yes, it is. +11
samir_ibrahim 58 Junior Poster

yeah.. You right.. But i want to 10,000.00.. How can make it.. Not depending where i place.. Please.... I stuck ...

Unless I did not miss something, I found adatapost answer is what you want

Dim n As Integer = 12345
TextBox1.Text = n.ToString("###,###.00")
MsgBox("Next")
Dim d As Double = 123456.123
TextBox1.Text = d.ToString("###,###.00")
samir_ibrahim 58 Junior Poster

As it looks for now, the label changes it's text to 100 when the label text is changed. But there is nothing that trigger the textchanged method.

Could you please make this little tiny small test for me?

Create a new form, add a label which is by default will be Label1
in Label1_TextChanged you just put

Msgbox ("Heyy, I had been triggered !!!")

Run the form and tell me your result ??

samir_ibrahim 58 Junior Poster

Ok, I mostly used Python to learn programming.. I am now trying to learn VB.. This is my problem..It seems that tutorial after tutorial I read has no examples as I am trying to do..

1. Dim x As Integer = 100
# this should make x = 100 right?
2.Private Sub Label4_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label4.TextChanged
# this should handle the lable4 to be ready to display something.
3. Label4.Text = x
# this should make x show up in label4 right? But it dose not..As I said im used to python and maybe I am still thinking that way..

Basicly I want to make x a number and make it show up and and be able to change if I so to choose to make it do so, but mostly I want it to show up in label4..

Hi Clueless86

All your approach and thinking are correct.

That should work fine if you declare the integer inside the Label4_TextChanged , where did you put Dim x As Integer = 100

samir_ibrahim 58 Junior Poster

not like that. like :

Private Sub Form_Load()
Dim x As Integer
x = 100
Label4.Caption = x
End Sub

Hi Abo Taher

I want to say thanks to you for the effort you did trying to help people in the forum, and for the effort helping the PO in his problem.

Just a couple of note
1- If you read the PO question you will notice he is trying to learn vb, so your answer should be somehow clear and simple and it has no mistake in it because that will confuse the PO more than he already confused trying to solve his problem.

2- your first word to him was "not like that. like :"
well, it seems that you are very sure about it, since you did not say "try this" or "test this way" ?
let me ask you this
A- Did you notice from his question that he is asking question about vb.net? you should notice that from his first line "Dim x As Integer = 100"
B- your answer works in vb6 and his question was in vb.net, do you know vb.net?

Just be careful when you post an answer especially if the person asking the question is newbie and still learning.

samir_ibrahim 58 Junior Poster

What is your db back-end?

samir_ibrahim 58 Junior Poster

Hi Sknake,
the line of code that is throwing the exception is "daLinStock.Update(ds)
When It tries to do the update I thing the dataset is empty but I don't know why.
Thanks

Where and how did you declare the variable "ds" ?

samir_ibrahim 58 Junior Poster

getting the following exception :

Object reference not set to an instance of an object.

Check if you have declared a public variable to an object exist on the form in the declaration section.

hth

samir_ibrahim 58 Junior Poster

Do you mean something like that?

Dim A1 = "Message1"
Dim A2 = "Message2"
Dim A3 = "Message3"

Dim B
B = "A1"
MsgBox(B) <-- should show "Message1"

B = "A2"
MsgBox(B) <-- should show "Message2"

etc ... ?

samir_ibrahim 58 Junior Poster
samir_ibrahim 58 Junior Poster

oledbcom.executereader is working without any errors.
and m using it because i want the last value to be fetched which i dont think is possible with executescalar.
m getting this error at the last line
oledbcom1.executenonquery()
plz help

That error will occur when you specify a parameter type which is diff than the field structure in the table.

in this line oledbcom1.Parameters.Add("@ID", OleDb.OleDbType.VarChar) check if VarChar is the correct type for ID which I doubt, and I guess it should be integer.

hth

samir_ibrahim 58 Junior Poster

Try this

SELECT Training.EmpID, Training.TrainingType, Employee.EmpName, EmpProfInfo.Des_ID, Designation.Designatio
FROM Designation RIGHT OUTER JOIN
Employee RIGHT OUTER JOIN
EmpProfInfo RIGHT OUTER JOIN
Training ON EmpProfInfo.EmpID = Training.EmpID ON Training.EmpID = Employee.EmpID ON Designation.Des_ID = EmpProfInfo.Des_ID
WHERE (Training.TrainingType <> 'Type1')

samir_ibrahim 58 Junior Poster

My answer may appear a little far from your question, but here how I look to it.

In every applications we all write these layers are exist, but they were all exist in one place. Suppose you create a form which include one textbox and save button, in the save button there is an insertion to the information written in the textbox after validation.

The good N-Tire is where you can reduce time and coding for your entire solution (not your single application). The "N" is Unknown number of layer that may exist to help build a good architecture design. where you can re-use what you have build in this application in another application even with another programming language.

I divide the project in 3 parts,
- Form Controls (Button, ListBox, etc...)
- Data handling (connecting, handling, data validating)
- Common Functions

In form design I mean subclassing of each form control using usercontrol and if necessary build an .ocx from it where I can use in other programming language. If I need to change the back color of textbox, I don't need to open each form and change the color of the textbox, I simply change it in one place in the usercontrol.

In data handling, I create a class for each database back-end I use, and I use this class whenever I am developing. Here is a sample

Public Class MySQL
    Public Function CreateMySQLConnectionADODB(ByVal Server, ByVal Database, ByVal UserName,
samir_ibrahim 58 Junior Poster

Well that is not gonna be easy (unless there is a built-in function in .net I am not aware of)

here is the closet thing I manage to reach.

Add FolderBrowseDialog

Dim ServerName = "server_name"
Dim AdminUserName = "Administrator"
Dim DomainName = "domain_name"
Dim AdminPassword = "administrator_password"
' Initialize WMI
Dim objSWbemLocator As New WbemScripting.SWbemLocator
'or Dim objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

' Connect to remote PC
Dim objSWbemServices = objSWbemLocator.ConnectServer(ServerName, "root\cimv2", AdminUserName, AdminPassword, "MS_409", "ntlmdomain:" + DomainName)
' Get Logical HDD from Remote PC
'Dim colHDDs = objSWbemServices.ExecQuery("Select * From Win32_LogicalDisk")
Dim colHDDs = objSWbemServices.ExecQuery("Select * From Win32_LogicalDisk where DriveType=3")
Dim StartFolder = "\\" & ServerName & "\" & Microsoft.VisualBasic.Left(colHDDs(0).name, 1) & "$"
FolderBrowserDialog1.SelectedPath = StartFolder
FolderBrowserDialog1.ShowDialog()
samir_ibrahim 58 Junior Poster

Just one question,

Is you sonia sardana and ritu verma are the same person?

I ask Sonia and you response, please clarify?

samir_ibrahim 58 Junior Poster

sender.ActiveElement.tagname

That Will return the HTML Tag name such as "A" "BODY" "INPUT" etc...

Thx very much...Can u plz tell me i m gng in d right way.....

Just follow the sign road and compare it with your map :)

What you are trying to do with your code?

samir_ibrahim 58 Junior Poster

Hi Sonia,

I Suggest using the ContextMenuShowing instead of MouseDown , as it seems that MouseDown is 1 click behind and don't give the current element but it gives the previous element that rightclick is occur on it.

Now, to get the element (I don't know what information you want) info, just put a debug point as I post in my example below and search under Sender.ActiveElement Replace the mouse down event with this.

Sub IEDoc_ContextMenuShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles IEDoc.ContextMenuShowing
    Dim ElementInfo = sender.ActiveElement.ID + vbTab + sender.ActiveElement.InnerHTML ' <-- Put debug point here and add sender to the watch window and search under activeelement
    Debug.Print(ElementInfo)
End Sub
samir_ibrahim 58 Junior Poster

but when i tried using the same model for the restore it give a massage that i do not have exclusive acces to perform the action

Backup and restore are totally different and they require different parameter to be filled.

So, What do you mean by using the same model for restore?

samir_ibrahim 58 Junior Poster

and just say "help me"

You forget to mention "ASAP". :D

Should I mark this post as solved?

samir_ibrahim 58 Junior Poster
samir_ibrahim 58 Junior Poster

You are very welcome :)

I suggest that you use the DataSet in design time in the current time. It is hard to do work with VB.Net alone, how about working with SQL Server as well, and both of them are new to you.

I know SQL Server before I get with VB.Net so that makes things a little easier because I know what I want except I need to know how to do it in vb.net instead of VFP.

Press: View >> server explorer
Press: Data >> show data sources

in the server explorer you can create the connection to the sql server (or any db backend)

in the data sources you can create Dataset depending on the connection you created in the server explorer.

Currently every time I create a dataset in VS I'm prompted for a connection string

I guess that is related to how you create the the connection.

Can you post step by step how you are creating the DataSet?

samir_ibrahim 58 Junior Poster

hi all,

I hope i am writing in the right forum, I don't have a question but a suggestion.

As you all know there is
- vb 2003/2005/2008/2010
- .Net 1.1 to 3.51 plus .Net 4 Beta
- Win XP, Vista, Windows 7, Win2003 win2008

I suggest that the user can fill the above when posting his question, so any one who is trying to help him can know the environment the user had.

It happens with me twice, once I post an answer to use LINQ and the user has vb2005 + .Net 2.0 and once a working code on XP SP2 giving wrong result on Windows 2003/2008

Keep the good work in this wonderful site and nice people..

Regards.

samir_ibrahim 58 Junior Poster

Guess what happened?!

You got infected and did you not create the anti-virus yet? ;)

Any help will be appreciated!

Help with what exactly? The above is correct. does it give any error?

samir_ibrahim 58 Junior Poster

I am still confused of what is your requirement and especially from mentioning "typed DataSet" (maybe it is me)

Any way, this is (my preferable way) how to connect to SQL Server,
' VS 2010 + MSSQL 2008

Dim _cnn As New SqlClient.SqlConnection("Data Source=server_name;Initial Catalog=database_name;User Id=user_name;Password=password;")

' Establiosh connection
_cnn.Open()
' Test if the connection is ok
Debug.Print(_cnn.State)

' We will use this to make loop though the result that will came after executing the query
Dim _dr As SqlClient.SqlDataReader

Dim _cmd As New SqlClient.SqlCommand

      
_cmd.Connection = _cnn
_cmd.CommandText = "select * from mytable where field1 = " & TextBox1.Text

_dr = _cmd.ExecuteReader '<-- Execute the query
While _dr.Read '<-- loop through the result
    Debug.Print(_dr("field1"))
End While

Now the above example does not check if the textbox is empty or null, to cover that you have multiple option.
1- create SP (store prpcedure) at the sql server and handle the null there http://www.eggheadcafe.com/conversation.aspx?messageid=33535029&threadid=33535026
CREATE PROCEDURE
2- assign a default value for the parameter in case of empty

3- check the Null by If

If TextBox1.Text = Nothing Then
    _cmd.CommandText = "select * from mytable "
Else
    _cmd.CommandText = "select * from mytable where field1 = " & TextBox1.Text
End If

Finally, if the above connection string for sql does not work on sql2005, get the connection string from here
Connection Strings

samir_ibrahim 58 Junior Poster

For your first question, and it is my own opinion, I prefer that you create a view on the SQL Server side, and call this view whenever you need it. (at least less coding)

For your second question regarding filter. That is a big question and cannot be answered directly unless you shrink it :)

It depend on how you connect to the SQL Server using (Dataset (design or coding), SQLClient.Command Object, or LINQ)

So what do use?

about your question if the query can be combined with the form control as you type it, AFAIK the answer is no, but you could combine the form control + query in the query string, for ex:

_sql = "Select * from mytable where field1 = " + text1.text

hth

samir_ibrahim 58 Junior Poster

The site is changed, and the text below which you are searching for "</span></b></font></span>" is no more available.

Good luck.

samir_ibrahim 58 Junior Poster

creating a file in the folder with userID & password.

The only way I know to do that is to create a folder and the file on a server itself, where you can set the permission as you like. Are you taking about folder and file on local HDD or server?

please help me ASAP

Why ASAP? i am not in hurry. are you?

keenly waiting for ur reply with "FULL CODE"

FULL CODE? Do you want a help file also?

samir_ibrahim 58 Junior Poster

As fast response, you have 2 things missing
Inet <-- is not declared
DivideText <-- which i guess it is a function is not there is your code.

You can stick with your code, and you can use my code if you find it better

Dim xmlHTTP
Dim URL As String
Set xmlHTTP = CreateObject("MSXML2.XMLHTTP")
URL = "http://www.perceler.com/getipadr1.php"
xmlHTTP.Open "GET", URL, False
xmlHTTP.Send
Debug.Print xmlHTTP.responseText
BillWebber commented: Nice of him to offer me some help. Thank you. +3
samir_ibrahim 58 Junior Poster

Hi rdefazio,

Dim DomainName as string = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties.DomainName.ToString()

I had tried your code, and it gives this result.

- It don't run on Vista local HDD neither UNC
- It works on XP SP2 Local HDD not UNC

I had given up searching to fix this, I am officially declare I had surrender :)

I will copy each exe to each pc local hdd and end this.

Thank you for tour time and effort.

samir_ibrahim 58 Junior Poster

Thank you for this class which I guess it will be very helpful in version 3 of my software :)

The problem in short is, some vb command works fine if the exe run from unc and some gives security warning.

The Line commented by you about the ip address is working fine since all the pc in the company work with ip4

I will give you an example

Environment.UserDomainName ' <-- Gives Error
Environment.UserName ' <-- works fine

The above both works fine if the exe exist on local HDD, if the exe exist in UNC "\\server\folder" the first will give an error and the second will work fine.

Why is that?

I had managed to get all the info I need except domain name.