태그 보관물: vs2008

C# SQLite Code Sample

P_20151127-092339

using System.Data.SQLite;   //  추가
string gsFilePath = System.IO.Directory.GetCurrentDirectory();
//  현재 디렉토리 가져오기 위함
// select sample
 
			string Conn = gsFilePath + "/Test.db";
			String dbConnection = String.Format("Data Source={0}", Conn);
			SQLiteConnection dbcon = new SQLiteConnection(dbConnection);
			dbcon.Open();
			SQLiteCommand qry = new SQLiteCommand("SELECT * FROM Test order by seq desc  limit 1", dbcon);
			DataTable dattbl = new DataTable();
			SQLiteDataReader reader = qry.ExecuteReader();
			dattbl.Load(reader);
			reader.Close();
			if (dattbl.Rows.Count > 0)
			{
				string Temp1= dattbl.Rows[0][0].ToString();
				int Temp2= int.Parse(dattbl.Rows[0][1].ToString());
				string Temp3= dattbl.Rows[0][2].ToString();
				string Temp4= dattbl.Rows[0][3].ToString();
				intTemp5= int.Parse(dattbl.Rows[0][4].ToString());
                         }
// insert sample
			string tempQry = string.Empty;
			try
			{
				string Conn = gsFilePath + "/Test2.db";
				String dbConnection = String.Format("Data Source={0}", Conn);
				SQLiteConnection dbcon = new SQLiteConnection(dbConnection);
				dbcon.Open();
				SQLiteCommand qry = new SQLiteCommand(" insert into WIRE (pt_no, SEQ, Wire_Code 
                                                                  ,Wire_nm, Wire_gram ) values(" + temA + ptno + temAE +																														                  
                                                                                            temA + seq + temAE +																														         
                                                                                            temA + Wire_Code + temAE +																														    
                                                                                            temA + Wire_nm + temAE +																														    
                                                                                            temA + Wire_gram + temA +																																
                                                                                            ")", dbcon);
				qry.ExecuteNonQuery();
				dbcon.Close();
			}
			catch (Exception)
			{
				throw;
			}
		}
// insert sample
 
			string tempQry = string.Empty;
 
			string Conn = gsFilePath + "/TEST2.db";
			String dbConnection = String.Format("Data Source={0}", Conn);
			SQLiteConnection dbcon = new SQLiteConnection(dbConnection);
			dbcon.Open();
			SQLiteCommand qry = new SQLiteCommand("delete from Table ", dbcon);			
			qry.ExecuteNonQuery();
			dbcon.Close();

C# Zebra TCP 프린트 Code

시리얼로 뽑는거야 전부다 아실꺼공

TCP 로 하는법은.. 이제 그 기반이 되어가니깐 ZT410을 쓰기 위하여..!!

using System.Net;
 
 
private void btn_TCPIPPrint(string ZPLString)
{
	string ipAddress = "192.168.20.238";   // Test ZT410 ip
	int port = 9100;		
 
	try
	{
		// Open connection
		System.Net.Sockets.TcpClient ZT410 = new System.Net.Sockets.TcpClient();
		ZT410.Connect(ipAddress, port);
 
		// Write ZPL String to connection
		System.IO.StreamWriter ZebraPrint = new System.IO.StreamWriter(ZT410.GetStream());
 
		ZebraPrint.Write(ZPLString);
		//writer.WriteLine(ZPLString);
 
		ZebraPrint.Flush();
 
		// Close Connection
 
		ZebraPrint.Close();
		ZT410.Close();
 
	}
 
	catch (Exception ex)
	{
 
		// Catch Exception
		MessageBox.Show(ex.ToString());
	}		
}

참 쉽지용…

물론 기억을 다 못하니 메모용…