Click here to Skip to main content
15,936,903 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear friends I am getting compilation error line no 1, please make the correction,

Thank you.
VB
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.SqlClient
Imports System.Configuration

Public Partial Class Registration
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(sender As Object, e As EventArgs)

	End Sub
	Protected Sub Button1_Click(sender As Object, e As EventArgs)
		Dim conn As New SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename="|DataDirectory|Copy of Regstr.mdf";Integrated Security=True;User Instance=True")
		conn.Open()

		Dim cmd As New SqlCommand((((((((("insert into Register values ('" + DropDownListdept.Text & "','") + txtempname.Text & "','") + DropDownListDesign.Text & "','") + DropDownListdays.Text & "','") + txtfrm.Text & "','") + txtto.Text & "','") + DropDownListleave.Text & "','") + txtresonforleav.Text & "','") + txtincharge.Text & "')", conn)


		cmd.ExecuteNonQuery()
		conn.Close()

		Label1.Text = "Your Data Stored Successfully"
	End Sub
End Class
Posted
Updated 8-Sep-12 0:06am
v2
Comments
bbirajdar 8-Sep-12 5:34am    
At this line 'Imports System.Collections.Generic' ?
Menon Santosh 8-Sep-12 6:03am    
post your error
Shiva from Bangalore, Karnataka 9-Sep-12 0:21am    
this is error;

Server Error in '/Mahesh' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0116: A namespace cannot directly contain members such as fields or methods

Source Error:


Line 1: Option Explicit On
Line 2: Imports Microsoft.VisualBasic
Line 3: Imports System.Collections.Generic

[no name] 8-Sep-12 9:14am    
Probably somewhere in this horrid line of code: Dim cmd As New SqlCommand((((((((("insert into Register values ('" + DropDownListdept.Text & "','") + txtempname.Text & "','") + DropDownListDesign.Text & "','") + DropDownListdays.Text & "','") + txtfrm.Text & "','") + txtto.Text & "','") + DropDownListleave.Text & "','") + txtresonforleav.Text & "','") + txtincharge.Text & "')", conn)

1 solution

The problem is in this line:

VB
Dim conn As New SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename="|DataDirectory|Copy of Regstr.mdf";Integrated Security=True;User Instance=True")


Change that into this:

Dim conn As New SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=""|DataDirectory|Copy of Regstr.mdf"";Integrated Security=True;User Instance=True")


Hope this helps.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900