|
I don't know about the SQL Server but I think the shift key on the laptop is broken...
|
|
|
|
|
Piyush Vardhan Singh wrote: but i can not access sql sever2005 so how i can access sql Please help me.
You're question is very vague. How are you trying to access SQL Server?? What error mesasges do you get?? If this is your code, what does the code look like???
|
|
|
|
|
hi,
i write following statement to filter dataset'tables
Dim IsItemExist As DataRow() = DatabaseCopy.Tables(0).Select("areaname='" & txtAreaName.Text.Trim & "'")
if txtAreaName.Text.Trim does not contains any single quote , then it works well & return proper result.but if txtAreaName.Text.Trim contains single quote(for example ab'cd) then it gives following error
Syntax error: Missing operand after 'cd' operator.
Please suggest that how can i resolve this error ? mean if filter criteria contains special character then how can i get proper result ?
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
In your example, you specified ab'cd . Does it work if you double-up the single quote mark? i.e.: ab''cd
|
|
|
|
|
sir,
how can i guess that, user enter single quote in text box ? if he enter any other character (in place of single quote) or does not enter any special character. Please notice my vb.net statement
Dim IsItemExist As DataRow() = DatabaseCopy.Tables(0).Select("areaname='" & txtAreaName.Text.Trim & "'")
here i have no idea that which value will be entered in this textbox. it may be simple words or digit or any other special character.
hope you understand my problem properly.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Rupesh Kumar Swami wrote: how can i guess that, user enter single quote in text box ?
At this point, who cares? All you're trying to do is narrow down a problem. So, TEST IT! What happens when the user enters two single quote marks (ab''cd )as opposed to one (ab'cd )??
|
|
|
|
|
ok sir,
i replace single quote as following
Dim itemName As String = """" & txtAreaName.Text.Trim.Replace("'", "''") & """"<br />
'Dim IsItemExist As DataRow() = DatabaseCopy.Tables(0).Select("areaname='" & txtAreaName.Text.Trim & "'")<br />
Dim IsItemExist As DataRow() = DatabaseCopy.Tables(0).Select("areaname='" & itemName & "'")
and above code works well. but if txtAreaName.Text contains double quote (for example abc"de) then how would i replace double quote and from which character ?
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
How to do reports in Visual Basic.
|
|
|
|
|
Vignesh Krishnan wrote: How to do reports in Visual Basic.
Like you would in any other language, I guess...
Seriously, it would depend on the tool you use, or you could write your own.
|
|
|
|
|
There are a bunch of reporting packages out there, like SQL Reporting Services and Crystal Reports to name a couple. Exactly what you do is up to the package that you use.
|
|
|
|
|
hai frnds
i m developing a web portal.
in that for a page i set the property "AutoPostBack=True" for few controls.
does there is any disadvantage for using this property for many times in a single page.
i mean, if page is postback to itself for several times in a single page
then is there any problem.
thanks in advance
vijay
devulapally_vijay@yahoo.co.in
|
|
|
|
|
This question has nothing to do with VB.NET and everything to do with ASP.NET. You should be asking this question in the ASP.NET Forum[^].
|
|
|
|
|
hai frnds
i m using Ms-access database as backend for my project.
i used the following code for retriving...
Dim con As New OleDbConnection("Provider=Microsoft.JET.OleDb.4.0;User Id=administrator;password=designstecpro;Data Source=D:/DataBaseBkp1-4/Master.mdb")
Dim da As New OleDbDataAdapter("select * from login", con)
Dim ds As New DataSet
da.Fill(ds, "login")
DataGridView1.DataSource = ds
but it is giving error like...
"Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
i set a password for my database.
when i remove the password for it then it is working fine....
can any one tell me wt would be the problem...
thanks in advance
vijay
devulapally_vijay@yahoo.co.in
|
|
|
|
|
vijaylumar wrote: i m using Ms-access database as backend for my project.
i used the following code for retriving...
Dim con As New OleDbConnection("Provider=Microsoft.JET.OleDb.4.0;User Id=administrator;password=designstecpro;Data Source=D:/DataBaseBkp1-4/Master.mdb")
Dim da As New OleDbDataAdapter("select * from login", con)
Dim ds As New DataSet
da.Fill(ds, "login")
DataGridView1.DataSource = ds
but it is giving error like...
"Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
i set a password for my database.
when i remove the password for it then it is working fine....
can any one tell me wt would be the problem...
You need to add the user name / password to the connection string.
|
|
|
|
|
hi,
try following connection string
connectionstring="Provider=Microsoft.jet.oledb.4.0;data source= D:/DataBaseBkp1-4/Master.mdb ;Jet OLEDB:Database Password=designstecpro"
i also doubt about path you specified
data source= D:/DataBaseBkp1-4/Master.mdb
is it desktop application ? if yes then
use backslash("\") in place of forward slash("/")
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Hi
I'm trying to make an app that opens a file with excel in vb.net.
I'm trying to separate the text in a sheet with TextToColumns, but i'm stuck on how to do that. I have tested this but get an error that "TextToColumns method in the Range class has failed". Here's what I tried:
Private Sub btnOPEN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOPEN.Click<br />
<br />
OpenFD.ShowDialog()<br />
Dim strfilename As String<br />
strfilename = OpenFD.FileName<br />
<br />
Dim xlApp As Excel.Application<br />
Dim xlWorkBook As Excel.Workbook<br />
Dim xlWorkSheet As Excel.Worksheet<br />
Dim Range As Excel.Range<br />
<br />
xlApp = CreateObject("Excel.Application")<br />
xlApp.Visible = True<br />
<br />
xlWorkBook = xlApp.Workbooks.Open(strfilename)<br />
xlWorkSheet = xlWorkBook.ActiveSheet<br />
Range = xlWorkSheet.Range("a1", "a70")<br />
Range.Font.Bold = True<br />
Range.TextToColumns("a3", Microsoft.Office.Interop.Excel. _<br />
XlTextParsingType.xlDelimited, _<br />
Microsoft.Office.Interop.Excel.XlTextQualifier. _<br />
xlTextQualifierDoubleQuote, _<br />
True, True, False, True, True, False, False, _<br />
False, False, False, False) <br />
End Sub
|
|
|
|
|
Member 4435051 wrote: Range.TextToColumns("a3", Microsoft.Office.Interop.Excel. _
XlTextParsingType.xlDelimited, _
Microsoft.Office.Interop.Excel.XlTextQualifier. _
xlTextQualifierDoubleQuote, _
True, True, False, True, True, False, False, _
False, False, False, False)
Looking at the docs on TextToColumns, you didn't specify the first arugment correctly. The method is looking for a Range object and you gave it a string ("A3") instead. I don't do Office interop, so this may be wrong, but I think you're looking for this or something very similar:
Range.TextToColumns(xlWorkSheet.Range("A3"), ...
|
|
|
|
|
Thank's a lot.
This help is what I really needed.
|
|
|
|
|
It did work great.
Thank's
|
|
|
|
|
Hello Friends,
I am using datagrid to display records from access db. I got the first field as ID which is a primary key. As users should not edit it i made that column as read only in the datagrid but i need that column to be editable when users tries to add a new record(row). I am using windows forms (vb.net). Could anyone solve this issue?
|
|
|
|
|
Member 3936356 wrote: I got the first field as ID which is a primary key. As users should not edit it i made that column as read only in the datagrid but i need that column to be editable when users tries to add a new record(row).
You really should not be allowing users to edit the primary key field. Assigning a primary key should be left up to the database, either by generating a key from entered data in a standardized format or by an autonumber.
|
|
|
|
|
Hello Friends,
I am newbie when it comes to vb.net and i need to import excel sheet into access db using vb.net application. Here is the code i use for now to upload excel sheet and it works perfectly but i when i upload the file again it should include only the new records by checking the existence of ID field which i use as primary key. For now it pops up the message"Table Exists already".Could anyone help me pls?
Dim AccessConnection As New System.Data.OleDb.OleDbConnection
Dim _conn As String
Dim SchemaTable As DataTable
AccessConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=somefile.mdb"
AccessConnection.Open()
SchemaTable = AccessConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, New Object() {Nothing, Nothing, "mytable"})
If SchemaTable.Rows.Count <> 0 Then
MsgBox("Table Exists already" )
Else
Dim _filename As String = "myexcelsheet.xls"
_conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & _filename & ";" & "Extended Properties=Excel 8.0;"
Dim _connection As OleDbConnection = New OleDbConnection(_conn)
Dim _command As OleDbCommand = New OleDbCommand
_command.Connection = _connection
Try
_command.CommandText = "SELECT * INTO [MS Access;Database=somefile.mdb].[accesstbname] FROM [Sheet1$]"
_connection.Open()
_command.ExecuteNonQuery()
MessageBox.Show("The Data Imported Successfully!")
Catch e1 As Exception
MessageBox.Show("Error!.Your Excel Spread Sheet has some problems.")
End Try
End If
|
|
|
|
|
Member 3936356 wrote: _command.CommandText = "SELECT * INTO [MS Access;Database=somefile.mdb].[accesstbname] FROM [Sheet1$]"
In order to do what you want, you have to retrieve the data from the Excel sheet into a DataTable, iterate over the rows in the DataTable, verify that the row's ID is NOT already in the database, then execute an INSERT query to add the new row to the table if it' doesn't already exist.
|
|
|
|
|
Thanks for you suggestions. But still as i am a newbie i donot have any idea about checking excel sheet rows against database unique id field and insert ones that does not exist. I expect some help in coding.
|
|
|
|
|
Can someone please look at this and make some suggestions on how to improve the performance of this snippet this is killing one of our apps.
Private Function fbParseParameters(ByVal sArgs() As String) As Boolean
Dim tTemp As String
'
fbParseParameters = True
Dim iII As Integer = 0
If sArgs.Length > 0 Then
' each parameter is broken into a seperate array item.
While iII < sArgs.Length
tTemp = sArgs(iII).ToUpper
' look at the parms, and figure out which is which...
If tTemp.IndexOf("DATABASEHOST=") > 0 Then
myConnectionInfo.tDatabaseHost = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("USERNAME=") > 0 Then
myConnectionInfo.tUserName = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("USERNUMBER=") > 0 Then
myConnectionInfo.lUserNumber = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("PASSWORD=") > 0 Then
myConnectionInfo.tPassword = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("LOCALE=") > 0 Then
myConnectionInfo.tCurrentLocaleCode = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("LOCALEDESCR=") > 0 Then
myConnectionInfo.tCurrentLocale = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("MODULE=") > 0 Then
strApplicationInfo.tCurrentModule = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("REPORT=") > 0 Then
strApplicationInfo.tReport = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("CLIENT=") > 0 Then
strSystemInfo.lCurrentClient = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("COMPONENTNUM=") > 0 Then
strSystemInfo.lComponentNum = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("ISTHERAPY=") > 0 Then
Dim tTemp2 As String
tTemp2 = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
If tTemp2 = "-1" Or tTemp2 = "0" Or tTemp2 = "1" Or tTemp2.ToUpper = "TRUE" Or tTemp2.ToUpper = "FALSE" Then
strSystemInfo.bIsTherapy = CBool(tTemp2)
End If
End If
If tTemp.IndexOf("PLANTYPE=") > 0 Then
strSystemInfo.tPlanType = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("GRIDMODE=") > 0 Then
strSystemInfo.tGridMode = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("HEADERNUMBER=") > 0 Then
strSystemInfo.lHeaderNum = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("DISCIPLINE=") > 0 Then
strSystemInfo.lDisciplineNum = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
If tTemp.IndexOf("THERAPISTNUM=") > 0 Then
strSystemInfo.lTherapistNum = tTemp.Substring(tTemp.IndexOf("=") + 1, _
(tTemp.Length - (tTemp.IndexOf("=") + 1)))
End If
iII += 1
End While
Else
fbParseParameters = False
Exit Function
End If
' We must at least have username, password, and database host in order to do anything...
If myConnectionInfo.tUserName = String.Empty Or _
myConnectionInfo.tPassword = String.Empty Or _
myConnectionInfo.tDatabaseHost = String.Empty Then
fbParseParameters = False
End If
End Function
Here is an example of the parm string
/DATABASEHOST=TEST/DATABASENAME=TEST /USERNAME=TEST /PASSWORD=TEST /LOCALE=GW /LOCALEDESCR=Glenwood /MODULE=CL /REPORT=TRMonthlyAttendance
Here is where it is loaded into the array
' must format these into an array ...
tParms = txtParm.Text.Split("/")
Dim iII As Integer
For iII = 1 To tParms.Length - 1
tParms(iII) = Trim("/" & tParms(iII))
Next
Humble Programmer
|
|
|
|
|